Sunday 27, Apr 2025
We are moved to new domain
Click -> www.ehowtonow.com
Monday, 10 July 2017

cp Copy Linux Command

cp


cp [options] file1 file2 cp [options] files directory

Description :

Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten).

Options 

-a, --archive
Preserve attributes of original files where possible. The same as -dpr.

-b, --backup
Back up files that would otherwise be overwritten.

-d, --no-dereference
Do not dereference symbolic links; preserve hard-link relationships between source and copy.

-f, --force
Remove existing files in the destination.

-i, --interactive
Prompt before overwriting destination files. On most systems, this flag is turned off by default except for the root user, who is normally prompted before overwriting files.

-l, --link
Make hard links, not copies, of nondirectories.

-p, --preserve
Preserve all information, including owner, group, permissions, and timestamps.

-P, --parents
Preserve intermediate directories in source. The last argument must be the name of an existing directory. For example, the command:

cp --parents jphekman/book/ch1 newdir

copies the file jphekman/book/ch1 to the file newdir/jphekman/book/ch1, creating intermediate directories as necessary.

-r, -R, --recursive
Copy directories recursively.

-S backup-suffix, --suffix=backup-suffix
Set suffix to be appended to backup files. This may also be set with the SIMPLE_BACKUP_SUFFIX environment variable. The default is ~. You need to explicitly include a period if you want one before the suffix (for example, specify .bak, not bak).

-s, --symbolic-link
Make symbolic links instead of copying. Source filenames must be absolute.

--sparse=[always|auto|never]
Handle files that have "holes" (are defined as a certain size but have less data). always creates a sparse file, auto creates one if the input file is sparse, and never creates a non-sparse file without holes.

-u, --update
Do not copy a file to an existing destination with the same or newer modification time.

-v, --verbose
Before copying, print the name of each file.

-V type, --version-control=type
Set the type of backups made. You may also use the VERSION_CONTROL environment variable. The default is existing. Valid arguments are:

t, numbered
Always make numbered backups.

nil, existing
Make numbered backups of files that already have them; otherwise, make simple backups.

never, simple
Always make simple backups.

-x, --one-file-system
Ignore subdirectories on other filesystems.

Example

Copy the contents of the guest directory recursively into the /archives/guest/ directory, and display a message for each file copied:

cd /archives
cp -av /home/guest guest
cp  /home/guest guest

Reference : http://www.linuxdevcenter.com

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer

Related Posts:

  • locale Linux Command locale locale [options] [name] Print report on current locale settings. Locales determine the country-specific settings for a system, including character encodings, the formatting of dates, honorifics, diagnostic messages,… Read More
  • useradd Linux Command useradd useradd [options] [user] System administration command. Create new user accounts or update default account information. Unless invoked with the -D option, user must be given. useradd will create new entries in syst… Read More
  • usermod Linux Command usermod usermod [options] user System administration command. Modify user account information. Options -c comment Comment field. -d dir Home directory. -e date Account expiration date. date is in the format MM/DD/YYYY; … Read More
  • rsh Linux Command rsh rsh [options] host [command] Execute command on remote host, or, if no command is specified, begin an interactive shell on the remote host using rlogin. The options can be specified before or after host. Use of rsh has… Read More
  • routed Linux Command routed routed [options] [logfile] TCP/IP command. Network routing daemon. routed is invoked by a privileged user at boot time to manage the Internet routing tables. The routing daemon uses a variant of the Xerox NS Routing… Read More
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: cp Copy Linux Command Rating: 5 Reviewed By: eHowToNow