1CP(1) User Commands CP(1)
2
3
4
6 cp - copy files and directories
7
9 cp [OPTION]... [-T] SOURCE DEST
10 cp [OPTION]... SOURCE... DIRECTORY
11 cp [OPTION]... -t DIRECTORY SOURCE...
12
14 Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
15
16 Mandatory arguments to long options are mandatory for short options
17 too.
18
19 -a, --archive
20 same as -dR --preserve=all
21
22 --attributes-only
23 don't copy the file data, just the attributes
24
25 --backup[=CONTROL]
26 make a backup of each existing destination file
27
28 -b like --backup but does not accept an argument
29
30 --copy-contents
31 copy contents of special files when recursive
32
33 -d same as --no-dereference --preserve=links
34
35 -f, --force
36 if an existing destination file cannot be opened, remove it and
37 try again (this option is ignored when the -n option is also
38 used)
39
40 -i, --interactive
41 prompt before overwrite (overrides a previous -n option)
42
43 -H follow command-line symbolic links in SOURCE
44
45 -l, --link
46 hard link files instead of copying
47
48 -L, --dereference
49 always follow symbolic links in SOURCE
50
51 -n, --no-clobber
52 do not overwrite an existing file (overrides a previous -i op‐
53 tion)
54
55 -P, --no-dereference
56 never follow symbolic links in SOURCE
57
58 -p same as --preserve=mode,ownership,timestamps
59
60 --preserve[=ATTR_LIST]
61 preserve the specified attributes (default: mode,ownership,time‐
62 stamps), if possible additional attributes: context, links,
63 xattr, all
64
65 --no-preserve=ATTR_LIST
66 don't preserve the specified attributes
67
68 --parents
69 use full source file name under DIRECTORY
70
71 -R, -r, --recursive
72 copy directories recursively
73
74 --reflink[=WHEN]
75 control clone/CoW copies. See below
76
77 --remove-destination
78 remove each existing destination file before attempting to open
79 it (contrast with --force)
80
81 --sparse=WHEN
82 control creation of sparse files. See below
83
84 --strip-trailing-slashes
85 remove any trailing slashes from each SOURCE argument
86
87 -s, --symbolic-link
88 make symbolic links instead of copying
89
90 -S, --suffix=SUFFIX
91 override the usual backup suffix
92
93 -t, --target-directory=DIRECTORY
94 copy all SOURCE arguments into DIRECTORY
95
96 -T, --no-target-directory
97 treat DEST as a normal file
98
99 -u, --update
100 copy only when the SOURCE file is newer than the destination
101 file or when the destination file is missing
102
103 -v, --verbose
104 explain what is being done
105
106 -x, --one-file-system
107 stay on this file system
108
109 -Z set SELinux security context of destination file to default type
110
111 --context[=CTX]
112 like -Z, or if CTX is specified then set the SELinux or SMACK
113 security context to CTX
114
115 --help display this help and exit
116
117 --version
118 output version information and exit
119
120 By default, sparse SOURCE files are detected by a crude heuristic and
121 the corresponding DEST file is made sparse as well. That is the behav‐
122 ior selected by --sparse=auto. Specify --sparse=always to create a
123 sparse DEST file whenever the SOURCE file contains a long enough se‐
124 quence of zero bytes. Use --sparse=never to inhibit creation of sparse
125 files.
126
127 When --reflink[=always] is specified, perform a lightweight copy, where
128 the data blocks are copied only when modified. If this is not possible
129 the copy fails, or if --reflink=auto is specified, fall back to a stan‐
130 dard copy. Use --reflink=never to ensure a standard copy is performed.
131
132 The backup suffix is '~', unless set with --suffix or SIM‐
133 PLE_BACKUP_SUFFIX. The version control method may be selected via the
134 --backup option or through the VERSION_CONTROL environment variable.
135 Here are the values:
136
137 none, off
138 never make backups (even if --backup is given)
139
140 numbered, t
141 make numbered backups
142
143 existing, nil
144 numbered if numbered backups exist, simple otherwise
145
146 simple, never
147 always make simple backups
148
149 As a special case, cp makes a backup of SOURCE when the force and
150 backup options are given and SOURCE and DEST are the same name for an
151 existing, regular file.
152
154 Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
155
157 GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
158 Report any translation bugs to <https://translationproject.org/team/>
159
161 Copyright © 2022 Free Software Foundation, Inc. License GPLv3+: GNU
162 GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
163 This is free software: you are free to change and redistribute it.
164 There is NO WARRANTY, to the extent permitted by law.
165
167 Full documentation <https://www.gnu.org/software/coreutils/cp>
168 or available locally via: info '(coreutils) cp invocation'
169
170
171
172GNU coreutils 9.1 May 2023 CP(1)