This article mainly shares with you the method of copying files between different Linux hosts. Copying files on the current host disk is very simple. Everyone is familiar with the cp command. I hope it can help you.
Usage:
cp [options] source dest cp [options] source... directory
Function description: Copy one file to another file, or copy several files to another directory.
options parameter description:
-a Copy the file status, permissions and other information as they are as much as possible.
-r If source contains subdirectories, copy recursively to the destination.
-f means force, forced execution. If a file with the same file name already exists at the destination, the file will be overwritten (delete it before copying it and then copy it).
Example:
(1) Copy the file aaa (already exists) and name it bbb:
cp aaa bbb
(2) Copy all PHP language files to project In the subdirectory:
cp *.php project
So if you want to copy files between different Linux hosts, there are two common methods:
(1) Use FTP, that is, install ftp Server on one Linux, so that another client program using ftp can copy files.
(2) Use the scp command. scp is a file copy with Security, based on ssh login. This method is more convenient to operate. In order to transfer faster, it is best to compress the file before operation.
A. To copy the current file to another remote host, you can use the following command:
scp /home/wwwroot/shop.tar.gz root@192.168.230.128:/home/root
Then you will be prompted to enter the login password of the root user of the other 192.168.230.128 host. , and then the copying begins.
B. To copy files from the remote host to the current system, you can use the following command:
scp root@/shop.tar.gz 192.168.230.128:/home/root/shop.tar.gz home/wwwroot/shop.tar.gz
Related recommendations:
The above is the detailed content of How to copy files between different Linux hosts. For more information, please follow other related articles on the PHP Chinese website!