Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to transfer files under Linux

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you the relevant knowledge of how to transfer files under Linux. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

Scp introduction

Scp is an abbreviation for secure copy, a command used to remotely copy files under Linux. Similar commands are cp, but cp is only copied locally, not across servers, and the scp transfer is encrypted. It may affect the speed slightly. When your server hard drive becomes read-only read only system, using scp can help you move the files out. In addition, scp is also very resource-free, will not increase the system load, at this point, rsync is far less than it. Although rsync is a little faster than scp, when there are a large number of small files, rsync will cause the hard disk I _ An O to be very high, while scp basically does not affect the normal use of the system. Scp uses ssh connection and encryption to improve data security when boasting machine replication. If ssh password-free login is configured between machines, there is no need to enter a password when using scp.

Installation of scp: both ends of the file transfer machine need to be installed

[root@yufu ~] # yum install openssh-clients-y

Command format: scp [parameters] [local host file path] [remote host path]

Parameter options:

-1 force the scp command to use the protocol ssh2

-2 force the scp command to use the protocol ssh3

-4 forces the scp command to use only IPv4 addressing

-6 force the scp command to use only IPv6 addressing

-B uses batch mode (transfer passwords or phrases are not asked during transfer)

-C allows compression. (pass the-C flag to ssh to turn on compression)

-p retains the modification time, access time and access rights of the original file. (it is recommended to retain attribute time information during transmission, otherwise it will cause the time to change and the incremental transmission will not be carried out.)

-Q does not display the transmission progress bar. (suitable for use in crontab task planning)

-r copy the entire directory recursively.

-v displays the output in detail. Scp and ssh (1) show debugging information for the entire process. This information is used to debug connections, verify, and configure problems.

-c cipher encrypts the data transfer in cipher, and this option is passed directly to ssh.

-F ssh_config specifies an alternative ssh configuration file, which is passed directly to ssh.

-I identity_file reads the key file used for the transfer from the specified file, and this parameter is passed directly to ssh.

-l limit limits the bandwidth that users can use, in Kbit/s.

-o ssh_option if you are accustomed to using the parameter passing method in ssh_config (5)

-P port Note is uppercase P, port is the port number used to specify the data transfer

-S program specifies the program used to encrypt the transmission. This program must be able to understand the options of ssh (1).

Use of scp: copy local host A files to host B: avut 192.168.214.190 Borex 192.168.214.187

[root@localhost tmp] # scp-p. / files/yum.log 192.168.214.187:/tmp/demo/The authenticity of host '192.168.214.187 (192.168.214.187)' can't be established.RSA key fingerprint is SHA256:BwJdXsDA6F5976fKx1cSxkGJ9/uYYI4zVJ2rd+/Cvj0.RSA key fingerprint is MD5:85:87:8b:17:d2:79:c7:91:11:46:78:b3:4d:9d:dd:5a.Are you sure you want to continue connecting (yes/no)? YesWarning: Permanently added '192.168.214.187' (RSA) to the list of known hosts.root@192.168.214.187's password:yum.log 100% 0.0KB/s 00:00

Check the B host file:

[root@yufu demo] # lsf3.log yum.log [root@yufu demo] # ll total dosage 0m r M R M M R M R M M R R M M R M M R R M R R M M R M, R M M R, M M R M, R M M R M, M M R M, R M, M, M M R M, M M M 1 root root March 31 22:38 f3.logMurray RWMI. 1 root root 0 March 31 22:36 yum.log

Copy the remote host to local

[root@localhost files] # scp-p 192.168.214.187:/tmp/demo/f3.log / tmp/files/root@192.168.214.187's password:f3.log 100% 0.0KB/s 00:00 [root@localhost files] # lsf3.log ff.txt yum.log

Copy directory

[root@localhost tmp] # scp-rp. / files/ 192.168.214.187:/tmp/demoroot@192.168.214.187's password:f3.log 100% 0 0.0KB/s 00:00 yum.log 100 00 .0KB / s 00:00 ff.txt 100% 5 7.3KB/s 00:00 [root@localhost tmp] #

Check the remote host directory

[root@yufu demo] # tree. └── files ├── app ├── f3.log ├── ff.txt └── yum.log2 directories, 3 filesrz sz (lrzsz)

The rz sz instruction enables file transfer between linux and windows, but requires Xshell or SecureCRT remote connection tools to be installed on the windows client.

The rz instruction and the sz instruction are a pair of upload and download instructions. Their software package is called lrzsz.

The rz sz instruction is easy to use. Execute the rz instruction, and the remote connection tool will pop up a windows file selection window, as long as you select the file to upload.

Installation of tools:

Yum install lrzsz-y

File upload:

File download:

Rsync

Rsync is a tool that enables incremental backups. With task planning, rsync can achieve timing or interval synchronization, and with inotify or sersync, trigger real-time synchronization can be achieved. Rsync can achieve remote copy of scp, local copy of cp, rm deletion and "ls-l" display file list and other functions.

These are all the contents of the article "how to transfer Files under Linux". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report