Linux in a Nutshell, Third Edition
by Ellen Siever, Stephen Spainhour, Jessica P. Hekman, Stephen Figgins
Name
cp
Synopsis
cp [options] file1 file2
cp [options] files directory
Description
Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten).
Options
- -a, --archive
Preserve attributes of original files where possible. Same as -dpR.
- -b, --backup
Back up files that would otherwise be overwritten.
- -d, --no-dereference
Do not dereference symbolic links; preserve hard link relationships between source and copy.
- -f, --force
Remove existing files in the destination.
- -i, --interactive
Prompt before overwriting destination files.
- -l, --link
Make hard links, not copies, of nondirectories.
- -p, --preserve
Preserve all information, including owner, group, permissions, and timestamps.
- -P, --parents
Preserve intermediate directories in source. The last argument must be the name of an existing directory. For example, the command:
cp --parents jphekman/book/ch1 newdircopies the file jphekman/book/ch1 to the file newdir/jphekman/book/ch1, creating intermediate directories as necessary.
- -r, -R, --recursive
Copy directories recursively.
- -S backup-suffix, --suffix= backup-suffix
Set suffix to be appended to backup files. This may also be set with the SIMPLE_BACKUP_SUFFIX environment variable. The default is ~. You need to explicitly include a period if you want one before the suffix (e.g., specify ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access