Javatpoint Logo
Javatpoint Logo

Linux cp | Linux Copy File

'cp' means copy. 'cp' command is used to copy a file or a directory.

To copy a file into the same directory syntax will be,

Linux File cp

In above snapshot, we have created a copy of 'docu' and named it as 'newdocu'. If in case, (in our case it is 'newdocu') alreade exists, then it will simply over write the earlier file.

To copy a file in a different directory

We have to mention the path of the destination directory.

In the snapshot below, earlier there is no 'text' file. After giving the command, 'text' file has been copied to the destination directory that is 'Desktop'.

Linux File cp

cp Options

cp -r To copy a directory along with its sub dirctories.
cp file1 file 2 directory name To copy multiple file or directories in a directory.
cp -backup To backup the existing file before over writing it.
cp -i Asks for confirmtion.
cp -l To create hard link file.
cp -p Preserves attribute of a file.
cp -u -v To make sure source file is newer then destination file.
Next TopicLinux mv command

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA