Home>Article>Operation and Maintenance> Can't copy folders in linux?
Linux can copy folders, just use the cp command. The cp command is used to copy files or directories. You can copy one or more directories to a specified directory. The syntax is "cp [option] source directory path target directory path"; if you want to copy a folder, the option value can be set to "-a" Or "-r", which can set the copy mode to recursive copy.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Linux can copy folders, just use the cp command.
cp command is mainly used to copy files and directories (folders). At the same time, with certain options, it can also copy the entire directory, compare the old and new files of the two files and upgrade them.
cp [选项] 源文件/目录 目标文件/目录
Options:
-a: Usually used when copying a directory. It retains links and file attributes, and copies directories recursively. Its function is equivalent to a set of -d, -p, and -r options. We will introduce these options one by one;
-d: If the source file is a soft link (invalid for hard links), the copied target file is also a soft link;
-i: Ask if the target file already exists , you will be asked whether to overwrite;
-l: Create the target file as a hard link file of the source file instead of copying the source file;
-s: Create the target file as a soft link file of the source file instead of copying the source file;
-p: After copying, the target file retains the attributes of the source file (including all author, group, permissions and time);
-r: recursive copy, used to copy the directory;
-u: if the target If the file is different from the source file, use this option to update the target file. This option can be used to upgrade and backup the file.
Example:
1. Copy the file to the folder
cp /home/downloads/xampp-linux-x64-7.3.6-0-installer.run /opt/
2. Copy the folder to the file Clip
cp -r /home/downloads/phpcms_v9_UTF8/install_package/ /opt/lampp/htdocs/
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of Can't copy folders in linux?. For more information, please follow other related articles on the PHP Chinese website!