Spread the love

Copy is very command in Ubuntu terminal. whenever we want to copy the directories or files copy command come in to the action. In this article we will lean to copy the directory, copy files, copy with hidden files, copy recursively, copy multiple files, copy with backup, copy interactively.

So, the basic copy command statement is below

cp [options] source destination

Or you can say

cp [options] old old

Copy a file in same folder Ubuntu terminal

To copy a single file in Ubuntu we can use below command

cp test.txt test2.txt

Here cp is used for copy command, test.txt is source file, test2.txt is destination file.

Copy a file in different folder Ubuntu terminal

cp test.txt folder_name/path/test2.txt

folder_name/path/test2.txt, we can copy in folder_name.

Copy a folder recursively Ubuntu terminal

Copy a folder with all content using -R options

cp -R source_folder destination_folder

Copy a file or folder interactively

-i option is used to interactively show the prompt before copy.

cp -i source_folder destination_folder

Copy specific extension file

In some case it requires to copy only some specific file format file then we can use

cp  *.txt destination_folder

Copy file or folder with backup

Sometimes we need take backup before copying the files so here is command

cp -b test.txt test2.txt

Leave a Reply