How to copy files between different Linux hosts

小云云
Release: 2018-03-20 15:53:35
Original
3220 people have browsed it

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
Copy after login

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
Copy after login

(2) Copy all PHP language files to project In the subdirectory:

cp *.php project
Copy after login

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
Copy after login

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
Copy after login

Related recommendations:

PHP implements file copy

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template