CP(1)

πŸ“¦
version 9.10 Β· 5 versions
, in ubuntu stonking

πŸ’– NAME πŸ’–

okay bestie, listen up β€” this is cp(1), the copy files and directories girlie of the GNU coreutils lineup. she's been doing this since forever and she EATS every time. 🫢


✨ SYNOPSIS ✨

cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...

🌸 DESCRIPTION 🌸

so the whole vibe is: copy SOURCE to DEST, or copy a whole bunch of SOURCE(s) into a DIRECTORY. that's it. that's the job. iconic. πŸ‘‘

heads up bestie: mandatory arguments to long options are also mandatory for the short options. so if the long one needs a value, the short one does too. no skipping. βœ‹

the options, in order, all of them, no crumbs left behind πŸ’…

  • -a, --archive β€” literally the same as -dR --preserve=all. the full-preservation combo meal. πŸ“
  • --attributes-only β€” don't copy the file data, just the attributes. personality only, no content. ngl it's giving "vibes but no substance" but make it intentional.
  • --backup[=CONTROL] β€” make a backup of every existing destination file.
  • -b β€” like --backup but she does not accept an argument. strict queen.
  • --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 narrates her own life, main character energy fr.
  • -f, --force β€” if an existing destination file can't be opened, remove it and try again. (this option is ignored when the -n option is also used, fyi)
  • -i, --interactive β€” prompt before overwrite. (overrides a previous -n option β€” yes she will ask, she's polite like that πŸ™ˆ)
  • -H β€” follow command-line symbolic links in SOURCE.
  • -L, --dereference β€” always follow symbolic links in SOURCE. zero fear, she goes where they point. 🌈
  • -P, --no-dereference β€” never follow symbolic links in SOURCE. she does NOT chase, she observes. πŸ’…
  • --keep-directory-symlink β€” follow existing symlinks to directories.
  • -l, --link β€” hard link files instead of copying. why copy when you can just ~link~ besties.
  • -n, --no-clobber β€” (deprecated) do not overwrite an existing file and do not fail. (overrides a -u or previous -i option). see also --update; equivalent to --update=none.
  • -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. down the rabbit hole we go πŸ‡
  • --reflink[=WHEN] β€” control clone/CoW copies. see below.
  • --remove-destination β€” remove each existing destination file before attempting to open it. (contrast with --force) β€” she's thorough, okay?!
  • --sparse=WHEN β€” control creation of sparse files. see below.
  • --strip-trailing-slashes β€” remove any trailing slashes from each SOURCE argument. de-cluttering, we love to see it.
  • -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 a yapper and honestly? we need that. πŸ—£οΈ
  • -x, --one-file-system β€” stay on this file system. no crossing boundaries, she has her limits.
  • -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.

okay lore time πŸ’–

ATTR_LIST is a comma-separated list of attributes. and the 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

the sparse files situation πŸ¦‹

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, explained 🌟

UPDATE controls which existing files in the destination are replaced:

  • all β€” the default operation when an --update option is not specified, and results in all existing files in the destination being replaced.
  • none β€” 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 β€” 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, the whole tea β˜•

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

one special little exception πŸ‘€

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. legends, honestly. thank you for your service 🫑


😭 REPORTING BUGS 😭


🌈 SEE ALSO 🌈

  • install(1)
  • Full documentation https://www.gnu.org/software/coreutils/cp β€” or available locally via: info '(coreutils) cp invocation'
  • Packaged by Ubuntu (9.10-1ubuntu2)
  • 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.

okay that's the whole thing bestie, you're officially a cp girlie now πŸ’…βœ¨ go forth and copy responsibly β€” this was GNU coreutils 9.10, August 2026, CP(1), and she ATE. mwah! πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from