Copy the files in the specified directory to the current directory and rename [root @ rehatroot] # cp ~ /. Bashrcbashrc_bakNO2. force copy the file from the specified directory to the current directory, regardless of whether the current directory contains the file [root @ rehatroot] # cp-f ~ /. BashrcbashrcN
Common commands for copying files and folders using CentOS
Cp
NO1. copy the files in the specified directory to the current directory and rename
[Root @ rehat root] # cp ~ /. Bashrc bashrc_bak
NO2. force copy the file from the specified directory to the current directory, regardless of whether the current directory contains the file
[Root @ rehat root] # cp-f ~ /. Bashrc
NO2. copy the specified directory to the current directory
[Root @ rehat root] # cp-r/root/test.
[Root @ rehat root] # cp-r/root/test /.
The two have the same effect. when copying a directory, all the last-level directories in the source path will be copied, including the directory itself.
NO3. copy files from the specified directory to the specified directory
[Root @ rehat root] # cp ~ /. Bashrc/bak/. bashrc
If the prompt is:
Cp: omitting directory
Use:
[Root @ rehat root] # cp-r ~ /. Bashrc/bak/. bashrc
If the prompt is:
Cp: overwrite
A slash is used:
[Root @ rehat root] #/cp-r-f ~ /. Bashrc/bak/. bashrc
NO4. during replication, all the attributes of the source file are also copied. If no parameter is specified, the properties of the target file and the source file may be inconsistent.
[Root @ rehat root] # cp-~ /. Bashrc/bak/. bashrc
NO5. if two folders need to be synchronized, one file is changed and the other file is changed, but ensure that the files of both files are up-to-date.
[Root @ rehat root] # cp-u/src/. bashrc/bak_src/bashrc