cp was part of Version 1 Unix.4 The version of cp bundled in GNU coreutils was written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.5
cp has three principal modes of operation. These modes are inferred from the type and count of arguments presented to the program upon invocation.
Copying a file to another file:
Copying file(s) to a directory
Copying a directory to a directory (-r or -R must be used)
Creating a copy of a file in the current directory:
This copies prog.c to prog.bak. If the prog.bak file does not already exist, the cp command creates it. If it does exist, the cp command replaces its contents with the contents of the prog.c file.
Copy two files in the current directory into another directory:
This copies the files jones to /home/nick/clients/jones and smith to /home/nick/clients/smith.
Copy a file to a new file and preserve the modification date, time, and access control list associated with the source file:
This copies the smith file to the smith.jr file. Instead of creating the file with the current date and time stamp, the system gives the smith.jr file the same date and time as the smith file. The smith.jr file also inherits the smith file's access control protection.
Copy a directory, including all its files and subdirectories, to another directory:
This copies the directory clients, including all its files, subdirectories, and the files in those subdirectories, to the directory customers/clients. Some Unix systems behave differently in this mode, depending on the termination of directory paths. Using cp -R /home/nick/clients/ /home/nick/customers on a GNU system it behaves as expected; however, on a BSD system, it copies all the contents of the "clients" directory, instead of the directory clients itself. The same happens in both GNU and BSD systems if the path of the source directory ends in . or .. (with or without trailing slash).
The copying of a file to an existing file is performed by opening the existing file in update mode, thereby preserving the files inode, which requires write access and results in the target file retaining the permissions it had originally.
"Cp(1) - Linux manual page". https://www.man7.org/linux/man-pages/man1/cp.1.html ↩
"GNU Coreutils: cp invocation". GNU. https://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html#cp-invocation ↩
"EFI Shells and Scripting". Intel. Retrieved 2013-09-25. http://software.intel.com/en-us/articles/efi-shells-and-scripting/ ↩
McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139. /wiki/Doug_McIlroy ↩
"Cp(1): Copy files/Directories - Linux man page". https://linux.die.net/man/1/cp ↩
"Progress(1) - Linux man page". https://linux.die.net/man/1/progress ↩
"Progress - Coreutils Progress Viewer". GitHub. 14 November 2021. https://github.com/Xfennec/progress ↩