Linux Views 4

Copying files with the Linux cp command

Copying files with the Linux cp command image 1

The cp command copies a given file into the current directory or another directory.

cp [option] [filename] [filename]

 Option Description 
 -a   Copies while keeping the original file’s attributes, structure, and so on as they are. 
 -b   When copying, if a file with the same name exists, creates a backup.
 -d   When copying, if the file is a symbolic link, copies the target of the symbolic link
 -f   If the destination file already exists, deletes it and then copies
 -i   When copying, if the same file exists, asks whether to overwrite it.
 -P   Copies the original file’s owner, group, permissions, and timestamps as they are
 -r   Also copies files and directories under the directory.

Command examples

Copies the original file’s attributes, structure, owner, group, permissions, and timestamps, including subdirectories

Copying files with the Linux cp command image 2

Reactions

Comments 0

A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.

Comments appear after a review. The password is used again to edit or delete.