In Linux, creating, copying, moving, and deleting files and directories can be done using a variety of command-line tools. Here are some commonly used commands for these tasks:
Creating Files and Directories:
touch: Creates a new empty file. For example, "touch newfile.txt" would create a new file named "newfile.txt".
mkdir: Creates a new directory. For example, "mkdir newdir" would create a new directory named "newdir".
Copying Files and Directories:
cp: Copies a file from one location to another. For example, "cp file.txt /home/john" would copy the file "file.txt" to the "john" directory within the "home" directory.
cp -r: Copies a directory from one location to another. For example, "cp -r directory /home/john" would copy the directory "directory" and all of its contents to the "john" directory within the "home" directory.
Moving Files and Directories:
mv: Moves a file from one location to another. For example, "mv file.txt /home/john" would move the file "file.txt" to the "john" directory within the "home" directory.
mv -r: Moves a directory from one location to another. For example, "mv directory /home/john" would move the directory "directory" and all of its contents to the "john" directory within the "home" directory.
Deleting Files and Directories:
rm: Deletes a file. For example, "rm file.txt" would delete the file "file.txt".
rm -r: Deletes a directory and all of its contents. For example, "rm -r directory" would delete the directory "directory" and all of its contents.
It is important to use caution when deleting files and directories, as these actions cannot be undone and can result in permanent data loss. Additionally, some system files and directories may be restricted and require administrative privileges to modify or delete.