Want to know the Linux command to handle the ordinary files? ,Here i shared Linux command through which you can easily handle the ordinary files.
Table of Contents
What is Ordinary files?
An ordinary file is a file on the system that contains data like text, or program instructions. To perform the various action like creating, modifying the file content and changing the permission, Linux have built command.
Handling ordinary files using Linux command:
1.mkdir
It ies used to create or make file directories on the file system.If the specifies directory doeest not already exixt,
mkdir creates it,more than directories can be specified when calling mkdir.
syntax: mkdir directory_name;
example: mkdir -m a=rwx directory1
Above example creates directory1 with read,write,executes permission.
option:-m:mode(file mode as in the chmod read,write)
-p:(parents):make parent directories as needed if no error exists.
-v:(verbase):print message for each created directories.
-z:set SE linux security context of each created directories to the default type.
2.rmdir:
rmdir utility removes the directory entry specified by each directory argument until the directory is empty.
argument ar process in the order given t remove both a parent directory and subdirectory.subdirectory must be specified
first so that directory is empty when rmdir tries to remove it.
example: rmdir directory_name
option: – -p:(parents):remove directory and its ancestor.
-v:(verbase):output to diagonstic for every directory processed
-d:remove the empty directory.
3.cd
It is used to change the current directory.when directory name is provided it changes to that directory.
syntax: cd directory name
if only cd is provided then it changes to the default directory.
4.mv(move)
It is used to rename or move the file in the file system.for movinf the file source path and destination path
ar provided as a parameter.
syntax: mv[option] source_destination
mv[option] source_directory
mv[option] directory_source
example: mv myfile.txt space c:/newfolder/
5.cp(copy)
It is used to make copies of file and directory
syntax: cp[option] suorce_destination
example: cp file1.txt file2.txt
option:-a:(archive): same as dr.
-b(backup):but doesn\’t take argument
-l:link instead of copy.
-n:not overwrite on existing file.
-r:recursive copy.
-v(varbase)
6.rm(remove)
rm command removes(delete) file or directory.
syntax: rm[option]filename
example: rm filename
option:– f(force):ignore non-existing file as argument.
-i:prompt before every removal.
-r:recursive remove.
-d:remove empty directory.
I:prompt before removing more than three file.
7.nano command
create a new file and open it immediately for editing the file using nano command. if you just want to create empty file then you can use touch command.
Syntax: nano filename
8.cat command
cat command in Linux used to view the file content in the terminal. Here is the syntax to view the file.
Syntax: cat filename
You can use less and more command to view the file content like pagination.
9.chown command in Linux
chown command is used when you want to apply ownership on the file.
Syntax: chown new_owner filename
These are some of the basic commands to handle ordinary files in Linux