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 -c deprecated, same as --preserve=context
66
67 --no-preserve=ATTR_LIST
68 don't preserve the specified attributes
69
70 --parents
71 use full source file name under DIRECTORY
72
73 -R, -r, --recursive
74 copy directories recursively
75
76 --reflink[=WHEN]
77 control clone/CoW copies. See below
78
79 --remove-destination
80 remove each existing destination file before attempting to open
81 it (contrast with --force)
82
83 --sparse=WHEN
84 control creation of sparse files. See below
85
86 --strip-trailing-slashes
87 remove any trailing slashes from each SOURCE argument
88
89 -s, --symbolic-link
90 make symbolic links instead of copying
91
92 -S, --suffix=SUFFIX
93 override the usual backup suffix
94
95 -t, --target-directory=DIRECTORY
96 copy all SOURCE arguments into DIRECTORY
97
98 -T, --no-target-directory
99 treat DEST as a normal file
100
101 -u, --update
102 copy only when the SOURCE file is newer than the destination
103 file or when the destination file is missing
104
105 -v, --verbose
106 explain what is being done
107
108 -x, --one-file-system
109 stay on this file system
110
111 -Z set SELinux security context of destination file to default type
112
113 --context[=CTX]
114 like -Z, or if CTX is specified then set the SELinux or SMACK
115 security context to CTX
116
117 --help display this help and exit
118
119 --version
120 output version information and exit
121
122 By default, sparse SOURCE files are detected by a crude heuristic and
123 the corresponding DEST file is made sparse as well. That is the behav‐
124 ior selected by --sparse=auto. Specify --sparse=always to create a
125 sparse DEST file whenever the SOURCE file contains a long enough se‐
126 quence of zero bytes. Use --sparse=never to inhibit creation of sparse
127 files.
128
129 When --reflink[=always] is specified, perform a lightweight copy, where
130 the data blocks are copied only when modified. If this is not possible
131 the copy fails, or if --reflink=auto is specified, fall back to a stan‐
132 dard copy. Use --reflink=never to ensure a standard copy is performed.
133
134 The backup suffix is '~', unless set with --suffix or SIM‐
135 PLE_BACKUP_SUFFIX. The version control method may be selected via the
136 --backup option or through the VERSION_CONTROL environment variable.
137 Here are the values:
138
139 none, off
140 never make backups (even if --backup is given)
141
142 numbered, t
143 make numbered backups
144
145 existing, nil
146 numbered if numbered backups exist, simple otherwise
147
148 simple, never
149 always make simple backups
150
151 As a special case, cp makes a backup of SOURCE when the force and
152 backup options are given and SOURCE and DEST are the same name for an
153 existing, regular file.
154
156 Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
157
159 GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
160 Report any translation bugs to <https://translationproject.org/team/>
161
163 Copyright © 2022 Free Software Foundation, Inc. License GPLv3+: GNU
164 GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
165 This is free software: you are free to change and redistribute it.
166 There is NO WARRANTY, to the extent permitted by law.
167
169 Full documentation <https://www.gnu.org/software/coreutils/cp>
170 or available locally via: info '(coreutils) cp invocation'
171
172
173
174GNU coreutils 9.1 January 2023 CP(1)