CP(1)

๐Ÿ’– CP(1) โ€” the copy command, but make it fashion ๐Ÿ’–

okay bestie, pull up a chair, because today we're learning cp(1) from the User Commands section of the manual, and honestly? it's giving main character energy. this is the girl who moves your files around, and she has opinions. ๐Ÿซถ


โœจ 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. that's it, that's the vibe. one file, or a whole little squad of files into a folder. ๐Ÿ’…

โš ๏ธ real talk: mandatory arguments to long options are mandatory for short options too. no exceptions, no cap. if you skip an argument an option needs, she's not gonna guess for you. ๐Ÿ˜ญ

๐ŸŽ€ the flags, one by one, we're not skipping a single one ๐ŸŽ€

  • -a, --archive โ€” same as -dR --preserve=all. the full-glam, everything-preserved copy.
  • --attributes-only โ€” don't copy the file data, just the attributes. the vibe without the contents, lowkey unhinged but valid.
  • --backup[=CONTROL] โ€” make a backup of each existing destination file.
  • -b โ€” like --backup but does not accept an argument. short and sweet, no extra input.
  • --copy-contents โ€” copy contents of special files when recursive.
  • -d โ€” same as --no-dereference --preserve=links.
  • --debug โ€” explain how a file is copied. Implies -v. she's narrating her own life. ๐Ÿ‘‘
  • -f, --force โ€” if an existing destination file cannot be opened, remove it and try again. heads up: this option is ignored when the -n option is also used.
  • -i, --interactive โ€” prompt before overwrite. this one overrides a previous -n option. she asks first, like a respectful queen. ๐Ÿ™ˆ
  • -H โ€” follow command-line symbolic links in SOURCE.
  • -L, --dereference โ€” always follow symbolic links in SOURCE.
  • -P, --no-dereference โ€” never follow symbolic links in SOURCE.
  • --keep-directory-symlink โ€” follow existing symlinks to directories.
  • -l, --link โ€” hard link files instead of copying.
  • -n, --no-clobber โ€” (deprecated) silently skip existing files. See also --update. yeah girl she's on her way out, use --update instead fr fr.
  • -p โ€” same as --preserve=mode,ownership,timestamps.
  • --preserve[=ATTR_LIST] โ€” preserve the specified attributes.
  • --no-preserve=ATTR_LIST โ€” don't preserve the specified attributes.
  • --parents โ€” use full source file name under DIRECTORY.
  • -R, -r, --recursive โ€” copy directories recursively. the whole tree, babes ๐ŸŒธ
  • --reflink[=WHEN] โ€” control clone/CoW copies. See below. ๐Ÿ‘€
  • --remove-destination โ€” remove each existing destination file before attempting to open it (contrast with --force).
  • --sparse=WHEN โ€” control creation of sparse files. See below. ๐Ÿ‘€
  • --strip-trailing-slashes โ€” remove any trailing slashes from each SOURCE argument. little cleanup moment. โœจ
  • -s, --symbolic-link โ€” make symbolic links instead of copying.
  • -S, --suffix=SUFFIX โ€” override the usual backup suffix.
  • -t, --target-directory=DIRECTORY โ€” copy all SOURCE arguments into DIRECTORY.
  • -T, --no-target-directory โ€” treat DEST as a normal file.
  • --update[=UPDATE] โ€” control which existing files are updated; UPDATE={all,none,none-fail,older(default)}.
  • -u โ€” equivalent to --update[=older]. See below.
  • -v, --verbose โ€” explain what is being done. she's keeping you in the loop, bestie. ๐Ÿ’ฌ
  • -x, --one-file-system โ€” stay on this file system. no wandering off. ๐Ÿšซ
  • -Z โ€” set SELinux security context of destination file to default type.
  • --context[=CTX] โ€” like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX.
  • --help โ€” display this help and exit.
  • --version โ€” output version information and exit.

๐Ÿงš what even is ATTR_LIST ๐Ÿงš

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
  • all โ€” for all attributes

๐Ÿซง sparse files, the whole tea ๐Ÿซง

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, and which files get replaced ๐Ÿ’ซ

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 do 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.


๐ŸŽ€ backups + suffixes ๐ŸŽ€

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. plot twist, but a documented one. ๐Ÿ“


โœจ AUTHOR โœจ

Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering. legends, all three. ๐Ÿ‘‘


โœจ REPORTING BUGS โœจ


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. like, none. zero. she said what she said. ๐Ÿ’€

โœจ SEE ALSO โœจ


and that's the whole page, bestie, we ate and left no crumbs. ๐Ÿ’…โœจ this lil masterpiece is GNU coreutils 9.12, dated September 2026, and yes the page header said CP(1) and the footer said CP(1) too, so we're full circle. mwah. ๐Ÿซถ๐ŸŽ€

๐Ÿ“ฆ where this page comes from