Latest web development tutorials

Linux cp command

Linux cp command

Linux command Daquan Linux command Daquan

Linux cp command is used to copy files or directories.

grammar

cp [options] source dest

or

cp [options] source... directory

Parameter Description:

  • -a: This option is typically when copying directories to use, it retains links, file properties, and copy all the contents of directory. Its role is equal dpR parameter combinations.
  • -d: When you copy a link reserved. Here, the link corresponds to the Windows system shortcuts.
  • -f: overwrite the destination file already exists without prompting.
  • -i: with the -f option to the contrary, before overwriting the destination file prompt asking the user to confirm whether to overwrite the destination file will be overwritten answer when "y".
  • -p: In addition to copying the contents of the file, but also modify time and access permissions are copied to the new file.
  • -r: If the given source file is a directory file, then copy all the subdirectories and files in this directory.
  • -l: do not copy the file, just build the linked files.

Examples

Using the command "cp" to copy the current directory "test /" all files to a new directory under "newtest", enter the following command:

$ cp –r test/ newtest          

Note: Use this command to copy the user directory, you must use the parameter "-r" or "-R".

Linux command Daquan Linux command Daquan