cp: Copy files and directories
August 7th, 2024 10:20 PM Mr. Q Categories: Command
Copy files and directories
Command: cp
Used to copy files and directories.
Sample Command and Output:
$ cp file1.txt /home/user/Documents/
$ ls /home/user/Documents/
file1.txtDescription:
- cp file1.txt /home/user/Documents/: Copies- file1.txtfrom the current directory to- /home/user/Documents/.
- ls /home/user/Documents/: Lists the contents of the destination directory to confirm that- file1.txthas been copied.
Sample Command and Output:
$ cp -r folder1/ /home/user/Backup/
$ ls /home/user/Backup/
folder1Description:
- cp -r folder1/ /home/user/Backup/: Copies the directory- folder1and its contents recursively to- /home/user/Backup/.
- ls /home/user/Backup/: Lists the contents of the destination directory to confirm that- folder1has been copied.