1CP(1)                            User Commands                           CP(1)
2
3
4

NAME

6       cp - copy files and directories
7

SYNOPSIS

9       cp [OPTION]... [-T] SOURCE DEST
10       cp [OPTION]... SOURCE... DIRECTORY
11       cp [OPTION]... -t DIRECTORY SOURCE...
12

DESCRIPTION

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       --debug
36              explain how a file is copied.  Implies -v
37
38       -f, --force
39              if an existing destination file cannot be opened, remove it  and
40              try  again  (this  option  is ignored when the -n option is also
41              used)
42
43       -i, --interactive
44              prompt before overwrite (overrides a previous -n option)
45
46       -H     follow command-line symbolic links in SOURCE
47
48       -l, --link
49              hard link files instead of copying
50
51       -L, --dereference
52              always follow symbolic links in SOURCE
53
54       -n, --no-clobber
55              do not overwrite an existing file (overrides a -u or previous -i
56              option). See also --update
57
58       -P, --no-dereference
59              never follow symbolic links in SOURCE
60
61       -p     same as --preserve=mode,ownership,timestamps
62
63       --preserve[=ATTR_LIST]
64              preserve the specified attributes
65
66       --no-preserve=ATTR_LIST
67              don't preserve the specified attributes
68
69       --parents
70              use full source file name under DIRECTORY
71
72       -R, -r, --recursive
73              copy directories recursively
74
75       --reflink[=WHEN]
76              control clone/CoW copies. See below
77
78       --remove-destination
79              remove  each existing destination file before attempting to open
80              it (contrast with --force)
81
82       --sparse=WHEN
83              control creation of sparse files. See below
84
85       --strip-trailing-slashes
86              remove any trailing slashes from each SOURCE argument
87
88       -s, --symbolic-link
89              make symbolic links instead of copying
90
91       -S, --suffix=SUFFIX
92              override the usual backup suffix
93
94       -t, --target-directory=DIRECTORY
95              copy all SOURCE arguments into DIRECTORY
96
97       -T, --no-target-directory
98              treat DEST as a normal file
99
100       --update[=UPDATE]
101              control    which    existing    files    are    updated;     UP‐
102              DATE={all,none,older(default)}.  See below
103
104       -u     equivalent to --update[=older]
105
106       -v, --verbose
107              explain what is being done
108
109       -x, --one-file-system
110              stay on this file system
111
112       -Z     set SELinux security context of destination file to default type
113
114       --context[=CTX]
115              like  -Z,  or  if CTX is specified then set the SELinux or SMACK
116              security context to CTX
117
118       --help display this help and exit
119
120       --version
121              output version information and exit
122
123       ATTR_LIST is a  comma-separated  list  of  attributes.  Attributes  are
124       'mode' for permissions (including any ACL and xattr permissions), 'own‐
125       ership' for user and group, 'timestamps' for file  timestamps,  'links'
126       for  hard  links,  'context' for security context, 'xattr' for extended
127       attributes, and 'all' for all attributes.
128
129       By default, sparse SOURCE files are detected by a crude  heuristic  and
130       the corresponding DEST file is made sparse as well.  That is the behav‐
131       ior selected by --sparse=auto.  Specify  --sparse=always  to  create  a
132       sparse  DEST  file  whenever the SOURCE file contains a long enough se‐
133       quence of zero bytes.  Use --sparse=never to inhibit creation of sparse
134       files.
135
136       UPDATE  controls  which existing files in the destination are replaced.
137       'all' is the default operation when an --update option  is  not  speci‐
138       fied,  and  results  in all existing files in the destination being re‐
139       placed.  'none' is similar to the --no-clobber option, in that no files
140       in the destination are replaced, but also skipped files do not induce a
141       failure.  'older' is the default operation when --update is  specified,
142       and  results  in  files being replaced if they're older than the corre‐
143       sponding source file.
144
145       When --reflink[=always] is specified, perform a lightweight copy, where
146       the data blocks are copied only when modified.  If this is not possible
147       the copy fails, or if --reflink=auto is specified, fall back to a stan‐
148       dard copy.  Use --reflink=never to ensure a standard copy is performed.
149
150       The   backup   suffix   is  '~',  unless  set  with  --suffix  or  SIM‐
151       PLE_BACKUP_SUFFIX.  The version control method may be selected via  the
152       --backup  option  or  through the VERSION_CONTROL environment variable.
153       Here are the values:
154
155       none, off
156              never make backups (even if --backup is given)
157
158       numbered, t
159              make numbered backups
160
161       existing, nil
162              numbered if numbered backups exist, simple otherwise
163
164       simple, never
165              always make simple backups
166
167       As a special case, cp makes a backup  of  SOURCE  when  the  force  and
168       backup  options  are given and SOURCE and DEST are the same name for an
169       existing, regular file.
170

AUTHOR

172       Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
173

REPORTING BUGS

175       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
176       Report any translation bugs to <https://translationproject.org/team/>
177
179       Copyright © 2023 Free Software Foundation, Inc.   License  GPLv3+:  GNU
180       GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
181       This  is  free  software:  you  are free to change and redistribute it.
182       There is NO WARRANTY, to the extent permitted by law.
183

SEE ALSO

185       Full documentation <https://www.gnu.org/software/coreutils/cp>
186       or available locally via: info '(coreutils) cp invocation'
187
188
189
190GNU coreutils 9.3               September 2023                           CP(1)
Impressum