Home » Linux » Basic Linux Commands » “cp” – Linux Copy Command

“cp” – Linux Copy Command

The “cp” (copy) command in Linux is used to copy files and directories from one location to another. cp commands keeps all the files at source intact and just duplicates the files to destination.

Below is the basic syntax of the “cp” command:

$ cp [OPTIONS] source_file target_file

Where source_file is the file you want to copy, and target_file is the location where you want to copy the file to.

Here are some common options used with the “cp” command:

  • -v – verbose mode, displays the progress of the copy operation
  • -r – copy directories recursively, including all subdirectories and files
  • -p – preserve the original file attributes, such as ownership and permissions
  • -f – force overwrite of an existing file
  • -u – only copy files that are newer than the destination file or missing from the destination

Some of the examples of cp command are as below,

$ cp file1.txt new_directory

copy a file called “file1.txt” from the current directory to another directory called “new_directory”

$ cp -r source_directory target_directory

This command copies source directory and all its contents recursively into target directory.


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment