--- layout: page category-page: fs category-title: FileSystem tags: directory list copy cp author: Mattia Hijman title: touch previous-page: pages/fs/rm.html --- In the first synopsis form, the cp utility copies the contents of the source_file to the target_file.
In the second synopsis form, the contents of each named source_file is copied to the destination target_directory.
The names of the files themselves are not changed. If cp detects an attempt to copy a file to itself, the copy will fail.
The following options are available:
For each destination file that already exists, its contents are overwrit- ten if permissions allow. Its mode, user ID, and group ID are unchanged unless the -p option was specified. In the second synopsis form, target_directory must exist unless there is only one named source_file which is a directory and the -R flag is speci- fied. If the destination file does not exist, the mode of the source file is used as modified by the file mode creation mask (umask, see csh(1)). If the source file has its set-user-ID bit on, that bit is removed unless both the source file and the destination file are owned by the same user. If the source file has its set-group-ID bit on, that bit is removed unless both the source file and the destination file are in the same group and the user is a member of that group. If both the set-user-ID and set-group-ID bits are set, all of the above conditions must be ful- filled or both bits are removed. Appropriate permissions are required for file creation or overwriting. Symbolic links are always followed unless the -R flag is set, in which case symbolic links are not followed, by default. The -H or -L flags (in conjunction with the -R flag) cause symbolic links to be followed as described above. The -H, -L and -P options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are determined by the last one specified. If cp receives a SIGINFO (see the status argument for stty(1)) signal, the current input and output file and the percentage complete will be written to the standard output.