Home>Article>Operation and Maintenance> How to copy and rename files in Linux
In Linux, you can use the "cp option source file or directory target file or directory" command to copy files and rename them. The cp command is used to copy files or directories. If two or more files or directories are specified at the same time, and the final destination is an existing directory, it will copy all previously specified files or directories to this directory.
#The operating environment of this tutorial: centos7 system, thinkpad t480 computer.
File/directory copy
cp [选项] 源文件或目录 目标文件或目录
This command can change the name while copying
eg,
cp abc.log def.log //abc.log 和 def.log 都是文件 cp -r test.quancheng/ quancheng //加 -r 参数,目录复制
Parameter description:
-a: means archive, also means copying all directories
-d: If the source file is a link file, copy the link file Attributes rather than the file itself
-f: force, if there are duplicates or other questions, the user will not be asked and forced to copy
-i: If the target file (destination) already exists, it will first ask whether to really operate when overwriting.
-l: Establish a hard link connection file , instead of copying the file itself
-p: Copy together with the file's attributes, instead of using the default attributes
-r: Copy recursively , used for directory copy operation
-s: Copy into a symbolic link file (symbolic link), that is, a "shortcut" file
-u: If the target file is older than the source file, update the target file
(recommended learning:linux tutorial)
The above is the detailed content of How to copy and rename files in Linux. For more information, please follow other related articles on the PHP Chinese website!