How to Use Unix Copy Command

In this tutorial, we will show you how to use the unix copy command. The unix commands to copy (Cp) is used to replicate or copy the files. This command can be used along with different attributes as well.



Step 1 – List the contents of the directory
Let’s look at an example over here.
First, let’s list the contents of the directory. With that done, you can see all the files current present in the directory.
List the directory contents

Step 2 – Specify the name of the folder and its destination
Over here, we will type “cp” followed by file name that we want to copy. After that, we will specify the destination where the file is to be copied.
Since we are copying the file to the desktop, we will type “forward slash desktop” over here.
Once we hit enter, you can see that the file has been copied to the desktop.
Enter the name of the folder and the destination

Step 3 – Use the CP command to copy certain types of files
Now let’s see how we can use the CP command that is the unix copy command to copy certain types of files. For that write,
cp asterisk followed by the file extension. For this tutorial let’s copy all the tar files. Now let’s type in the destination over here as well.
Now when we hit enter, you can see that the tar files have been copied to the desktop.
Work the CP command to copy certain types of files

Step 4 – Copy all contents in the directory
Now what if you want to copy all the contents in the directory, for that, write:
“cp -v *.*\Desktop”
Once you hit enter, you will notice that all the files have been copied to the desktop.
And that’s it, with the above steps you can learn how to use unix commands to copy in Linux.
Copy the directory contents