FACTOID # 54: The Mall in Washington, D.C. is 1.4 times larger than Vatican City.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Cp (Unix)
Wikibooks
Wikibooks has more about this subject:
Guide to UNIX commands: File system utilities#cp

cp is the command entered in a Unix shell to copy a file from one place to another, possibly on a different filesystem. The original file remains unchanged, and the new file may have the same or a different name. Image File history File links This is a lossless scalable vector image. ... Image File history File links Wikibooks-logo-en. ... In computing, a command is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. ... Screenshot of a sample Bash session, taken on Gentoo Linux. ... A computer file is a collection of information that is stored in a computer system and can be identified by its full path name. ... See Filing system for this term as it is used in libraries and offices In computing, a file system is a method for storing and organizing computer files and the data they contain to make it easy to find and access them. ...


The following sections refer to the AIX version of cp. Versions of the cp command from other operating systems may have different usage and flags.

Contents

Usage

To Copy a File to another File

 cp [ -f ] [ -H ] [ -i ] [ -p ][ -- ] SourceFile TargetFile 

To Copy a File to a Directory

 cp [ -f ] [ -H ] [ -i ] [ -p ] [ -r | -R ] [ -- ] SourceFile ... TargetDirectory 

To Copy a Directory to a Directory

 cp [ -f ] [ -H ] [ -i ] [ -p ] [ -- ] { -r | -R } SourceDirectory ... TargetDirectory 

Flags

-f (force) – specifies removal of the target file if it cannot be opened for write operations. The removal precedes any copying performed by the cp command.


-H – makes the cp command copy symbolic links. The default is to follow symbolic links, that is, to copy files to which symbolic links point.


-i (interactive) – prompts you with the name of a file to be overwritten. This occurs if the TargetDirectory or TargetFile parameter contains a file with the same name as a file specified in the SourceFile or SourceDirectory parameter. If you enter y or the locale's equivalent of y, the cp command continues. Any other answer prevents the cp command from overwriting the file.


-p (preserve) – duplicates the following characteristics of each SourceFile/SourceDirectory in the corresponding TargetFile and/or TargetDirectory:

  • The time of the last data modification and the time of the last access.
  • The user ID and group ID creation of view is always depent on unix cp

.

  • The file permission bits and the SUID and SGID bits.

setuid and setgid are Unix terms, which are short for Set User ID and Set Group ID, respectively. ... Setuid is a UNIX term, and is short for Set User ID. Setuid, also sometimes referred to as suid, is an access right flag that can be assigned to files and directories on a UNIX based operating system. ...

Examples

To make a copy of a file in the current directory, enter:

 cp prog.c prog.bak 

This copies prog.c to prog.bak. If the prog.bak file does not already exist, the cp command creates it. If it does exist, the cp command replaces it with a copy of the prog.c file.


To copy a file in your current directory into another directory, enter:

 cp jones /home/nick/clients 

This copies the jones file to /home/nick/clients/jones.


To copy a file to a new file and preserve the modification date, time, and access control list associated with the source file, enter:

 cp -p smith smith.jr 

This copies the smith file to the smith.jr file. Instead of creating the file with the current date and time stamp, the system gives the smith.jr file the same date and time as the smith file. The smith.jr file also inherits the smith file's access control protection.


To copy all the files in a directory to a new directory, enter:

 cp /home/janet/clients/* /home/nick/customers 

This copies only the files in the clients directory to the customers directory.


To copy a directory, including all its files and subdirectories, to another directory, enter:

 cp -R /home/nick/clients /home/nick/customers 

This copies the clients directory, including all its files, subdirectories, and the files in those subdirectories, to the customers/clients directory.


To copy a specific set of files to another directory, enter:

 cp jones lewis smith /home/nick/clients 

This copies the jones, lewis, and smith files in your current working directory to the /home/nick/clients directory.


To use pattern-matching characters to copy files, enter:

 cp programs/*.c . 

This copies the files in the programs directory that end with .c to the current directory, signified by the single . (dot). You must type a space between the c and the final dot.


Related Unix commands

  • cpio – copy an entire directory structure from one place to another
  • tar – create an archive of files
  • link – system call to create a link to a file or directory
  • ln – create a link to a file or directory
  • mv – move a file or directory
  • rm – remove a file or directory
  • unlink – system call to remove a file or directory
  • chmod – change permissions on a file or directory
  • chown – change ownership on a file or directory
  • chgrp – change group on a file or directory

CPIO is both the name of a binary utility, and a form of digital archive. ... In computing, the tar file format is a type of archive file format: the Tape ARchive format. ... link is a command line utility included with Unix-like operating systems. ... The ln command is used on Unix-like systems to create links between files. ... The correct title of this article is . ... The title given to this article is incorrect due to technical limitations. ... unlink is a command line utility written for use with the Unix-like operating systems. ... The chmod command (abbreviated from change mode) is a shell command in Unix and Unix-like environments. ... chown is a Unix command used to change the recorded owner of a computer file. ... The chgrp command is used by unprivileged users on Unix-like systems to change the group associated with a file. ...

See also

This is a list of Unix programs. ...

External links


  Results from FactBites:
 
Cp (Unix) - Wikipedia, the free encyclopedia (665 words)
cp is the command entered in a Unix shell to copy a file from one place to another, possibly on a different filesystem.
Versions of the cp command from other operating systems may have different usage and flags.
cp [ -f ] [ -h ] [ -i ] [ -p ] [ -- ] { -r
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.