Copy Multiple Files Using cp command in Linux - Complete guide ?

The cp command in Linux is used to copy files and directories by using the command line. This command also allows you to move multiple files and folders at once while preserving their backup and attribute information. So the cp command is very useful for Linux users.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux System configuration queries.

In this context, we shall look into how to copy multiple files using the cp command in Linux.


1. What is the syntax to copy a file of the cp command ?

It is given below:

$ cp [filename] [filename2]


2. What is the Syntax to copy multiple files of the cp command ?

You must provide a filename and destination directory to do this.

The syntax is:

$ cp [filename] [filename1] [folder name]/


3. What is the Syntax to copy a directory of the cp command ?

To copy the directory we must use the -r option:

$ cp -r foldername/ foldername 1


4. What is the Syntax to copy multiple directories of the cp command ?

The syntax is:

$ cp -r foldername foldername 1 foldername 2

The destination folder will be at the end.


5. How to Backup when copying files ?

Let's use the -b option to backup when copying files:

$ cp -b [filename] [filename2]

For example, we will backup the hello.pl file:

$ cp -b hello.pl hellobk.pl


[Need help in fixing Linux system issues ? We can help you. ]

This article covers how to copy multiple files using the cp command in Linux. In fact, cp is the command entered in a Unix and Linux shell to copy a file from one place to another, possibly on a different filesystem. The original file remains unchanged, and the new file may have the same or a different name.

Related Posts