cp, mv, rm

cp” command is used to copy files and directories. It requires at least two arguments.

To copy file file1 to a new file file2, issue “cp file1 file2” command. file2 will have the same contents as file1, but it will have new date stamp. Modifying one of the files will not affect the other file.

To copy file1 and file2 to a different directory, issue “cp file1 file2 <path_to_new_dir>”. File <path_to_new_dir>/file1 will have the same contents as file1, and file <path_to_new_dir>/file2 will have the same contents as file2, but they will have new date stamps.

To copy directory dir1 with all the files and subdirectories to a different directory, issue “cp -r dir1 <path_to_new_dir>”.

mv” command is used to move or rename files and directories. It also requires at least two arguments.

To rename file file1 to file2, issue “mv file1 file2” command. Note that after being renamed, file will still have old time stamp.

To move file1 and file2 to a different directory, issue “mv file1 file2 <path_to_new_dir>”. To move directory dir1 with all the files and subdirectories to a different directory, issue “mv dir1 <path_to_new_dir>”.

rm” command is used to remove files and directories. It requires at least one argument. Be careful with this command so that you don’t delete files that you meant to keep. To remove directory dir1 with all the files and subdirectories, issue “rm -r dir1”.