How to transfer files between local and linux

Common ways to transfer files between local and Linux servers: scp command, sftp command, lrzsz program, xftp software.

1. The lrzsz program

1. Use xshell software to ssh to the Linux server.

2. Enter the rz command and press Enter to check whether it is installed. If it is not installed, execute yum -y install lrzsz to install it.

3. After the installation is complete, enter rpm to check whether the installation is correct.

4. Use rz, rz -be to upload local files to linux. Use sz to download files on linux to the local.

Two, scp command

 1. Use cmd locally to open the command line window of the system.

 2. Upload local files/folders to linux.

scp 本地文件路径+文件名 远程主机用户名@ip:需要上传到远程主机的路径
scp -r 本地文件路径+文件夹名 远程主机用户名@ip:需要上传到远程主机的路径
例:
scp /Users/pc/Desktop/test.png [email protected]:/root
scp -r /Users/pc/Desktop/test [email protected]:/root

3. Transfer the files on the server to the local.

scp 远程主机用户名@ip:服务器上存放文件的路径  下载到本地的文件路径
scp -r 远程主机用户名@ip:服务器上存放文件的路径  下载到本地的文件路径
例:
scp [email protected]:/root/test.png /Users/pc/Desktop
scp -r [email protected]:/root/test /Users/mac/Desktop

Three, sftp command

1. cmd opens the local command line

2. Establish sftp connection

sftp username@ip  //sftp 用户名@服务器IP地址

3. View the current local path and destination host path

 lpwd: display the local path, pwd: display the remote path.

(Under sftp, the operation of the destination host is the original shell statement, but for the syntax of the local environment, you only need to add an l in front of the command )

4. Upload files/folders locally to the server.

put 本地文件路径 目的主机路径
put -r 本地文件夹路径 目的主机路径
例:
put  D:/test.txt  /home/test/ 
sftp> lcd D:/
sftp> cd /home/test
sftp> put text.txt
把本地的D:/目录下面的text.txt文件上传到远程服务器的/home/test目录下。

5. Download the server file/folder to the local.

get 远程路径/文件名 本地路径
get -r 远程路径/文件名 本地路径
sftp> cd /home/test
sftp> lcd D:/test
sftp> get -r log
把远程服务器的/home/test目录下面的log文件夹下载到本地服务器的D:/test目录下。

Four, xftp software

1. Open the xftp software and create a new session. Enter name, host address, select sftp protocol, port 22, username and password to connect.

 2. Drag files left and right to transfer files to each other.

 

Guess you like

Origin blog.csdn.net/weixin_50094651/article/details/127916622