CP
Section: User Commands (1)
Updated: February 2026
Index
Return to Main Contents
NAME
cp - copy files and directories
SYNOPSIS
cp
[
,OPTION/]... [
,-T/]
,SOURCE DEST/
cp
[
,OPTION/]...
,SOURCE/...
,DIRECTORY/
cp
[
,OPTION/]...
,-t DIRECTORY SOURCE/...
DESCRIPTION
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-a'-a, --archiveX'tty: link'
-
same as -dR --preserve=,all/
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-attribute-only'--attributes-onlyX'tty: link'
-
don't copy the file data, just the attributes
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-backup'--backup[=CONTROL]X'tty: link'
-
make a backup of each existing destination file
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-b'-bX'tty: link'
-
like --backup but does not accept an argument
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-cop-contents'--copy-contentsX'tty: link'
-
copy contents of special files when recursive
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-d'-dX'tty: link'
-
same as --no-dereference --preserve=,links/
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-debug'--debugX'tty: link'
-
explain how a file is copied. Implies -v
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-f'-f, --forceX'tty: link'
-
if an existing destination file cannot be opened, remove it and try
again (this option is ignored when the -n option is also used)
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-i'-i, --interactiveX'tty: link'
-
prompt before overwrite (overrides a previous -n option)
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-H'-HX'tty: link'
-
follow command-line symbolic links in SOURCE
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-L'-L, --dereferenceX'tty: link'
-
always follow symbolic links in SOURCE
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-P'-P, --no-dereferenceX'tty: link'
-
never follow symbolic links in SOURCE
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-kee-director-symlink'--keep-directory-symlinkX'tty: link'
-
follow existing symlinks to directories
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-l'-l, --linkX'tty: link'
-
hard link files instead of copying
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-n'-n, --no-clobberX'tty: link'
-
(deprecated) silently skip existing files. See also --update
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-p'-pX'tty: link'
-
same as --preserve=,mode,ownership,timestamps/
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-preserve'--preserve[=ATTR_LIST]X'tty: link'
-
preserve the specified attributes
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-n-preserve'--no-preserve=ATTR_LISTX'tty: link'
-
don't preserve the specified attributes
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-parents'--parentsX'tty: link'
-
use full source file name under DIRECTORY
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-R'-R, -r, --recursiveX'tty: link'
-
copy directories recursively
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-reflink'--reflink[=WHEN]X'tty: link'
-
control clone/CoW copies. See below
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-remov-destination'--remove-destinationX'tty: link'
-
remove each existing destination file before attempting to open it
(contrast with --force)
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-sparse'--sparse=WHENX'tty: link'
-
control creation of sparse files. See below
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-stri-trailin-slashes'--strip-trailing-slashesX'tty: link'
-
remove any trailing slashes from each SOURCE argument
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-s'-s, --symbolic-linkX'tty: link'
-
make symbolic links instead of copying
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-S'-S, --suffix=,SUFFIXX'tty: link'/
-
override the usual backup suffix
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-t'-t, --target-directory=,DIRECTORYX'tty: link'/
-
copy all SOURCE arguments into DIRECTORY
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-T'-T, --no-target-directoryX'tty: link'
-
treat DEST as a normal file
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-update'--update[=UPDATE]X'tty: link'
-
control which existing files are updated;
UPDATE={all,none,none-fail,older(default)}
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-u'-uX'tty: link'
-
equivalent to --update[=,older/]. See below
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-v'-v, --verboseX'tty: link'
-
explain what is being done
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-x'-x, --one-file-systemX'tty: link'
-
stay on this file system
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-Z'-ZX'tty: link'
-
set SELinux security context of destination file to default type
- X'tty: link https://www.gnu.org/software/coreutils/manual/coreutils.html#c-context'--context[=CTX]X'tty: link'
-
like -Z, or if CTX is specified then set the
SELinux or SMACK security context to CTX
- X'tty: link https://www.gnu.org/software/coreutils/cp#c-help'--helpX'tty: link'
-
display this help and exit
- X'tty: link https://www.gnu.org/software/coreutils/cp#c-version'--versionX'tty: link'
-
output version information and exit
ATTR_LIST is a comma-separated list of attributes. Attributes are 'mode' for
permissions (including any ACL and xattr permissions), 'ownership' for user
and group, 'timestamps' for file timestamps, 'links' for hard links, 'context'
for security context, 'xattr' for extended attributes, and 'all' for all
attributes.
By default, sparse SOURCE files are detected by a crude heuristic and the
corresponding DEST file is made sparse as well. That is the behavior
selected by --sparse=,auto/. Specify --sparse=,always/ to create a sparse DEST
file whenever the SOURCE file contains a long enough sequence of zero bytes.
Use --sparse=,never/ to inhibit creation of sparse files.
UPDATE controls which existing files in the destination are replaced.
'all' is the default operation when an --update option is not specified,
and results in all existing files in the destination being replaced.
'none' is like the --no-clobber option, in that no files in the
destination are replaced, and skipped files do not induce a failure.
'none-fail' also ensures no files are replaced in the destination,
but any skipped files are diagnosed and induce a failure.
'older' is the default operation when --update is specified, and results
in files being replaced if they're older than the corresponding source file.
By default or with --reflink=,auto/, cp will try a lightweight copy, where the
data blocks are copied only when modified, falling back to a standard copy
if this is not possible. With --reflink[=,always/] cp will fail if CoW is not
supported, while --reflink=,never/ ensures a standard copy is performed.
The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable. Here are the values:
- none, off
-
never make backups (even if --backup is given)
- numbered, t
-
make numbered backups
- existing, nil
-
numbered if numbered backups exist, simple otherwise
- simple, never
-
always make simple backups
As a special case, cp makes a backup of SOURCE when the force and backup
options are given and SOURCE and DEST are the same name for an existing,
regular file.
AUTHOR
Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
REPORTING BUGS
Report bugs to:
bug-coreutils@gnu.org
Report Gentoo bugs to: https://bugs.gentoo.org/
GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
General help using GNU software: <https://www.gnu.org/gethelp/>
Report any translation bugs to <https://translationproject.org/team/>
SEE ALSO
install(1)
Full documentation <https://www.gnu.org/software/coreutils/cp>
or available locally via: info aq(coreutils) cp invocationaq
Packaged by Gentoo (9.10 (p0))
Copyright © 2026 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- AUTHOR
-
- REPORTING BUGS
-
- SEE ALSO
-