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.txt
Description:
cp file1.txt /home/user/Documents/
: Copiesfile1.txt
from the current directory to/home/user/Documents/
.ls /home/user/Documents/
: Lists the contents of the destination directory to confirm thatfile1.txt
has been copied.
Sample Command and Output:
$ cp -r folder1/ /home/user/Backup/
$ ls /home/user/Backup/
folder1
Description:
cp -r folder1/ /home/user/Backup/
: Copies the directoryfolder1
and its contents recursively to/home/user/Backup/
.ls /home/user/Backup/
: Lists the contents of the destination directory to confirm thatfolder1
has been copied.