Linux File Operation Commands
Linux File Operation Commands
In Linux, everything is treated as a file, whether it is a text document, a program, or even a device. To manage files and directories (folders) effectively, Linux provides a set of simple yet powerful commands. These commands help users create, copy, move, and delete files and directories through the command-line interface (CLI). Understanding these basic file operations is essential for anyone beginning their journey with Linux.
cp Command
The cp command is used to copy files and directories from one location to another.
Example:
$ cp file1.txt backup/
This command copies file1.txt to the backup directory.
mv Command
The mv command is used to move or rename files and directories.
Example:
$ mv oldname.txt newname.txt
This command renames oldname.txt to newname.txt.
rm Command
The rm command is used to remove (delete) files and directories.
Example:
$ rm unwanted.txt
This command deletes the file named unwanted.txt.
touch Command
The touch command is used to create an empty file or update the timestamp of an existing file.
Example:
$ touch newfile.txt
This command creates a new empty file named newfile.txt.
mkdir Command
The mkdir command is used to create new directories.
Example:
$ mkdir myfolder
This command creates a new directory called myfolder.
rmdir Command
The rmdir command is used to remove empty directories.
Example:
$ rmdir myfolder
This command removes the empty directory named myfolder.
cat Command
The cat command is used to display the content of a file or to create a new file by typing its contents.
Example:
$ cat file1.txt
This command displays the content of file1.txt on the terminal.