Linux and other Linux distributions The cp command is used to copy a single file, group file, directory from one location to another. With the help of this command, you can copy the file from one location to another with any other name where the data of the file will not change, only the name of the file will change.
Syntax:
cp [OPTIONS] SOURCE DESTINATION
Copy Single File
- If you want to copy the file from one place to another first write the cp command then after the cp command type the name of the source file which you want to copy and then Write the destination path where you want to paste the copy file.
cp Source_File_Name Dest_File_Name cp File1 /root

Copy more than One File
- If You want to copy multiple files from one location to another, First Write the Cp command, then you have to write the name of all the files with a signal space, and then Write the destination Path.
cp data1 data2 data3 data4 /home

- If you want to copy the directory from one place to another, then for this you have to use the R option after the CP command
cp -R Src_directory Dest_Path cp -R TECH /Root

- i(interactive) I mean interactive copy, if you want to overwrite with the file that exists in the destination location, you have to use the R option. Before overwriting the file, the system will take the confirmation from the user and the user has to type ‘y’
cp -i data1 /root

- -f(force)If you are not able to copy regular or another Special Permission File and you want to copy files and directories forcefully then you should use the ‘f’ option.

- –v(Verbose) if you want to see the process of copying files and Directory From source to Destination then Use the -v option.
cp -rvi /etc /root

- Copying using * wildcard The * wildcard represents anything. If you have lots of files and directories in your source location and want to copy all those files and dirs to destination, then you have two options, the first way is to copy files one by one and the second smart way is this That you can use a * wildcard to copy all the files located in the source at once. As you can see below, 5 files have been copied together with the help of * wildcard.
cp data* /home

- –
RÂ (recursive) If you want to copy all the files and subdirectories created inside the directory then use the -R option.
cp -rvi Source_Dir Destination_Path cp -rvi /etc/ /var

Conclusion
Now we have learned how to copy files from one location to another with the help of the Linux cp command. To know more options related to this command, run the man cp command.
share copy file and Directory over the network use SCP (Secure Copy) and sync. If have any doubts, Questions,s, and Feedback related to this article feel free to leave a comment.
Also Read : Linux Basic Command with Example
Also, Visit Our Other Blog Simiservice.com
- Top 20 Highest Salary Jobs : Lucrative Careers with Best Salaries - 5 April 2025
- Types of Operating System (OS): Features,Types And Uses - 5 April 2025
- 15 Features of Operating System You Should Know - 4 April 2025



