Enhancing Skills

cp: Copy files and directories

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/: Copies file1.txt from the current directory to /home/user/Documents/.
  • ls /home/user/Documents/: Lists the contents of the destination directory to confirm that file1.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 directory folder1 and its contents recursively to /home/user/Backup/.
  • ls /home/user/Backup/: Lists the contents of the destination directory to confirm that folder1 has been copied.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.