Print this page
667 cp support for -a flag
   1 '\" te

   2 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
   3 .\" Copyright 1989 AT&T
   4 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
   5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   6 .\" http://www.opengroup.org/bookstore/.
   7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   8 .\"  This notice shall appear on any product containing this material.
   9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
  10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  12 .TH CP 1 "Oct 30, 2007"
  13 .SH NAME
  14 cp \- copy files
  15 .SH SYNOPSIS
  16 .LP
  17 .nf
  18 \fB/usr/bin/cp\fR [\fB-fip@/\fR] \fIsource_file\fR \fItarget_file\fR
  19 .fi
  20 
  21 .LP
  22 .nf
  23 \fB/usr/bin/cp\fR [\fB-fip@/\fR] \fIsource_file\fR... \fItarget\fR
  24 .fi
  25 
  26 .LP
  27 .nf
  28 \fB/usr/bin/cp\fR \fB-r\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR] [\fB-fip@/\fR] \fIsource_dir\fR... \fItarget\fR
  29 .fi
  30 
  31 .LP
  32 .nf
  33 \fB/usr/bin/cp\fR \fB-R\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR] [\fB-fip@/\fR] \fIsource_dir\fR... \fItarget\fR
  34 .fi
  35 
  36 .LP
  37 .nf
  38 \fB/usr/xpg4/bin/cp\fR [\fB-fip@/\fR] \fIsource_file\fR \fItarget_file\fR
  39 .fi
  40 
  41 .LP
  42 .nf
  43 \fB/usr/xpg4/bin/cp\fR [\fB-fip@/\fR] \fIsource_file\fR... \fItarget\fR
  44 .fi
  45 
  46 .LP
  47 .nf
  48 \fB/usr/xpg4/bin/cp\fR \fB-r\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR] [\fB-fip@/\fR] \fIsource_dir\fR... \fItarget\fR
  49 .fi
  50 
  51 .LP
  52 .nf
  53 \fB/usr/xpg4/bin/cp\fR \fB-R\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR] [\fB-fip@/\fR] \fIsource_dir\fR... \fItarget\fR
  54 .fi
  55 
  56 .SH DESCRIPTION
  57 .sp
  58 .LP
  59 In the first synopsis form, neither \fIsource_file\fR nor \fItarget_file\fR are
  60 directory files, nor can they have the same name. The \fBcp\fR utility copies
  61 the contents of \fIsource_file\fR to the destination path named by
  62 \fItarget_file\fR. If \fItarget_file\fR exists, \fBcp\fR overwrites its
  63 contents, but the mode (and \fBACL\fR if applicable), owner, and group
  64 associated with it are not changed. The last modification time of
  65 \fItarget_file\fR and the last access time of \fIsource_file\fR are set to the
  66 time the copy was made. If \fItarget_file\fR does not exist, \fBcp\fR creates a
  67 new file named \fItarget_file\fR that has the same mode as \fIsource_file\fR
  68 except that the sticky bit is not set unless the user is super-user. In this
  69 case, the owner and group of \fItarget_file\fR are those of the user, unless
  70 the setgid bit is set on the directory containing the newly created file. If
  71 the directory's setgid bit is set, the newly created file has the group of the
  72 containing directory rather than of the creating user. If \fItarget_file\fR is
  73 a link to another file, \fBcp\fR overwrites the link destination with the
  74 contents of \fIsource_file\fR; the link(s) from \fItarget_file\fR remains.
  75 .sp
  76 .LP
  77 In the second synopsis form, one or more \fIsource_file\fRs are copied to the
  78 directory specified by \fItarget\fR. It is an error if any \fIsource_file\fR is
  79 a file of type directory, if \fItarget\fR either does not exist or is not a
  80 directory.
  81 .sp
  82 .LP
  83 In the third or fourth synopsis forms, one or more directories specified by
  84 \fIsource_dir\fR are copied to the directory specified by \fItarget\fR. Either
  85 the \fB-r\fR or \fB-R\fR must be specified. For each \fIsource_dir\fR, \fBcp\fR
  86 copies all files and subdirectories.
  87 .SH OPTIONS
  88 .sp
  89 .LP
  90 The following options are supported for both \fB/usr/bin/cp\fR and
  91 \fB/usr/xpg4/bin/cp\fR:
  92 .sp
  93 .ne 2









  94 .na
  95 \fB\fB-f\fR\fR
  96 .ad
  97 .RS 6n
  98 Unlink. If a file descriptor for a destination file cannot be obtained, this
  99 option attempts to unlink the destination file and proceed.
 100 .RE
 101 
 102 .sp
 103 .ne 2
 104 .na
 105 \fB\fB-H\fR\fR
 106 .ad
 107 .RS 6n
 108 Takes actions based on the type and contents of the file referenced by any
 109 symbolic link specified as a \fIsource_file\fR operand.
 110 .sp
 111 If the \fIsource_file\fR operand is a symbolic link, then \fBcp\fR copies the
 112 file referenced by the symbolic link for the \fIsource_file\fR operand. All
 113 other symbolic links encountered during traversal of a file hierarchy are


   1 '\" te
   2 .\" Copyright 2013 Nexenta Systems, Inc. All rights reserved.
   3 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
   4 .\" Copyright 1989 AT&T
   5 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
   6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   7 .\" http://www.opengroup.org/bookstore/.
   8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   9 .\"  This notice shall appear on any product containing this material.
  10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
  11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  13 .TH CP 1 "Apr 15, 2013"
  14 .SH NAME
  15 cp \- copy files
  16 .SH SYNOPSIS
  17 .LP
  18 .nf
  19 \fB/usr/bin/cp\fR [\fB-afip@/\fR] \fIsource_file\fR \fItarget_file\fR
  20 .fi
  21 
  22 .LP
  23 .nf
  24 \fB/usr/bin/cp\fR [\fB-afip@/\fR] \fIsource_file\fR... \fItarget\fR
  25 .fi
  26 
  27 .LP
  28 .nf
  29 \fB/usr/bin/cp\fR [\fB-r\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR]] [\fB-afip@/\fR] \fIsource_dir\fR... \fItarget\fR
  30 .fi
  31 
  32 .LP
  33 .nf
  34 \fB/usr/bin/cp\fR [\fB-R\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR]] [\fB-afip@/\fR] \fIsource_dir\fR... \fItarget\fR
  35 .fi
  36 
  37 .LP
  38 .nf
  39 \fB/usr/xpg4/bin/cp\fR [\fB-afip@/\fR] \fIsource_file\fR \fItarget_file\fR
  40 .fi
  41 
  42 .LP
  43 .nf
  44 \fB/usr/xpg4/bin/cp\fR [\fB-afip@/\fR] \fIsource_file\fR... \fItarget\fR
  45 .fi
  46 
  47 .LP
  48 .nf
  49 \fB/usr/xpg4/bin/cp\fR [\fB-r\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR]] [\fB-afip@/\fR] \fIsource_dir\fR... \fItarget\fR
  50 .fi
  51 
  52 .LP
  53 .nf
  54 \fB/usr/xpg4/bin/cp\fR [\fB-R\fR | \fB-R\fR [\fB-H\fR | \fB-L\fR | \fB-P\fR]] [\fB-afip@/\fR] \fIsource_dir\fR... \fItarget\fR
  55 .fi
  56 
  57 .SH DESCRIPTION
  58 .sp
  59 .LP
  60 In the first synopsis form, neither \fIsource_file\fR nor \fItarget_file\fR are
  61 directory files, nor can they have the same name. The \fBcp\fR utility copies
  62 the contents of \fIsource_file\fR to the destination path named by
  63 \fItarget_file\fR. If \fItarget_file\fR exists, \fBcp\fR overwrites its
  64 contents, but the mode (and \fBACL\fR if applicable), owner, and group
  65 associated with it are not changed. The last modification time of
  66 \fItarget_file\fR and the last access time of \fIsource_file\fR are set to the
  67 time the copy was made. If \fItarget_file\fR does not exist, \fBcp\fR creates a
  68 new file named \fItarget_file\fR that has the same mode as \fIsource_file\fR
  69 except that the sticky bit is not set unless the user is super-user. In this
  70 case, the owner and group of \fItarget_file\fR are those of the user, unless
  71 the setgid bit is set on the directory containing the newly created file. If
  72 the directory's setgid bit is set, the newly created file has the group of the
  73 containing directory rather than of the creating user. If \fItarget_file\fR is
  74 a link to another file, \fBcp\fR overwrites the link destination with the
  75 contents of \fIsource_file\fR; the link(s) from \fItarget_file\fR remains.
  76 .sp
  77 .LP
  78 In the second synopsis form, one or more \fIsource_file\fRs are copied to the
  79 directory specified by \fItarget\fR. It is an error if any \fIsource_file\fR is
  80 a file of type directory, if \fItarget\fR either does not exist or is not a
  81 directory.
  82 .sp
  83 .LP
  84 In the third or fourth synopsis forms, one or more directories specified by
  85 \fIsource_dir\fR are copied to the directory specified by \fItarget\fR. Either
  86 the \fB-r\fR or \fB-R\fR must be specified. For each \fIsource_dir\fR, \fBcp\fR
  87 copies all files and subdirectories.
  88 .SH OPTIONS
  89 .sp
  90 .LP
  91 The following options are supported for both \fB/usr/bin/cp\fR and
  92 \fB/usr/xpg4/bin/cp\fR:
  93 .sp
  94 .ne 2
  95 .na
  96 \fB\fB-a\fR\fR
  97 .ad
  98 .RS 6n
  99 Archive mode. Same as -RpP.
 100 .RE
 101 
 102 .sp
 103 .ne 2
 104 .na
 105 \fB\fB-f\fR\fR
 106 .ad
 107 .RS 6n
 108 Unlink. If a file descriptor for a destination file cannot be obtained, this
 109 option attempts to unlink the destination file and proceed.
 110 .RE
 111 
 112 .sp
 113 .ne 2
 114 .na
 115 \fB\fB-H\fR\fR
 116 .ad
 117 .RS 6n
 118 Takes actions based on the type and contents of the file referenced by any
 119 symbolic link specified as a \fIsource_file\fR operand.
 120 .sp
 121 If the \fIsource_file\fR operand is a symbolic link, then \fBcp\fR copies the
 122 file referenced by the symbolic link for the \fIsource_file\fR operand. All
 123 other symbolic links encountered during traversal of a file hierarchy are