In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Linux system how to copy files and folders to the remote server, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Copying files from one server to another, or locally to remotely, is one of the daily tasks of Linux administrators.
I don't think anyone will disagree, because wherever you are, it's one of your daily operations. There are many ways to deal with this task, and we try to summarize it. You can choose a method you like. Of course, looking at other orders can help you in other places.
I have tested all the commands and scripts in my own environment, so you can use them directly in your daily work.
Usually people prefer scp because it is one of the native commands native command for file copying. But the other commands listed in this article are also useful, so I suggest you give it a try.
File replication can be easily done in the following four ways.
Scp: copy files between two hosts on the network, it uses ssh for file transfer, and uses the same authentication method, with the same security.
Rsync: is a fast and outstanding multi-function file copy tool. It can replicate locally, between other hosts through a remote shell, or with a remote rsync daemon, daemon.
Pscp: a program that copies files to multiple hosts in parallel. It provides many features, such as configuring secret-free transfer for scp, saving output to files, and timeout control.
Prsync: also a program that copies files to multiple hosts in parallel. It also provides many features, such as configuring secret-free transfer for ssh, saving output to files, and timeout control.
Method 1: how do I use the scp command on Linux to copy files / folders from the local system to the remote system?
The scp command allows us to copy files / folders from the local system to the remote system.
I will copy the output.txt file from the local system to 2g. Under the / opt/backup folder of the CentOS .com remote system.
# scp output.txt root@2g.CentOS.com:/opt/backupoutput.txt 100% 2468 2.4KB/s 00:00
Copy two files output.txt and passwd-up.sh from the local system to the / opt/backup folder on the remote system 2g.CentOs.com.
# scp output.txt passwd-up.sh root@2g.CentOS.com:/opt/backupoutput.txt 100% 2468 2.4KB/s 00:00passwd-up.sh 100% 877 0.9KB/s 00:00
Copy the shell-script folder from the local system to the / opt/back folder on the remote system 2g.CentOs.com.
This will be copied to / opt/back along with all the files in the shell-script folder.
# scp-r / home/daygeek/2g/shell-script/ root@:/opt/backup/output.txt 100% 2468 2.4KB/s 00:00ovh.sh 100% 76 0.1KB/s 00:00passwd-up.sh 100% 877 0.9KB/s 00:00passwd-up1.sh 100% 7 0.0KB/s 00:00server-list.txt 100% 23 0.0KB/s 00:00
Method 2: how do I use scp commands and Shell scripts on Linux to copy files / folders to multiple remote systems?
If you want to copy the same file to multiple remote servers, you need to create a small shell script like the one below.
Also, you need to add the server to the server-list.txt file. Ensure that after the addition is successful, each server should have a separate line.
In the end, the script you want looks like this:
# filehouse copy.shemake scp / home/daygeek/2g/shell-script/output.txt root@$server:/opt/backupdone binamp sh for server in `filecopyright list.txt`do scp /
When you are finished, set executable permissions to the file-copy.sh file.
# chmod + x file-copy.sh
Finally, run the script to complete the replication.
#. / file-copy.shoutput.txt 100% 2468 2.4KB/s 00:00output.txt 2468 2.4KB/s 00:00
Use the following script to copy multiple files to multiple remote servers.
# filehouse copy.shemake scp / home/daygeek/2g/shell-script/output.txt passwd-up.sh root@$server:/opt/backupdone binamp sh for server in `filecopyright list.txt`do scp /
The following results show that all two files are copied to both servers.
#. / file-cp.shoutput.txt 100% 2468 2.4KB/s 00:00passwd-up.sh 100% 877 0.9KB/s 00:00output.txt 100% 2468 2.4KB/s 00:00passwd-up.sh 100% 877 0.9KB/s 00:00
Use the following script to recursively copy folders to multiple remote servers.
# filehouse copy.shrunken binamp for server in `more server- list.txt`do scp-r / home/daygeek/2g/shell-script/ root@$server:/opt/backupdone
The output of the above script.
#. / file-cp.shoutput.txt / 2468 2.4KB/s 00:00ovh.sh / 76 0.1KB/s 00:00passwd-up.sh / 877 0.9KB/s 00:00passwd-up1.sh / 7 0.0KB/s 00:00server-list.txt / 23 0.0KB/s 00:00output.txt / 2468 2.4KB/s 00:00ovh.sh / 76 0.1KB/s 00:00passwd-up.sh / 877 0.9KB / s 00:00passwd-up1.sh 100% 7 0.0KB/s 00:00server-list.txt 100% 23 0.0KB/s 00:00
Method 3: how do I use the pscp command on Linux to copy files / folders to multiple remote systems?
The pscp command allows us to copy files directly to multiple remote servers.
Use the following pscp command to copy a single file to the remote server.
# pscp.pssh-H 2g.CentOS.com / home/daygeek/2g/shell-script/output.txt / opt/backup [1] 18:46:11 [SUCCESS] 2g.CentOS.com
Use the following pscp command to copy multiple files to the remote server.
# pscp.pssh-H 2g.CentOS.com / home/daygeek/2g/shell-script/output.txt ovh.sh / opt/backup [1] 18:47:48 [SUCCESS] 2g.CentOS.com
Use the following pscp command to recursively copy the entire folder to the remote server.
# pscp.pssh-H 2g.CentOS.com-r / home/daygeek/2g/shell-script/ / opt/backup [1] 18:48:46 [SUCCESS] 2g.CentOS.com
Use the following pscp command to copy a single file to multiple remote servers.
# pscp.pssh-h server-list.txt / home/daygeek/2g/shell-script/output.txt / opt/backup [1] 18:49:48 [SUCCESS] 2g.CentOS.com [2] 18:49:48 [SUCCESS] 2g.Debian.com
Use the following pscp command to copy multiple files to multiple remote servers.
# pscp.pssh-h server-list.txt / home/daygeek/2g/shell-script/output.txt passwd-up.sh / opt/backup [1] 18:50:30 [SUCCESS] 2g.Debian.com [2] 18:50:30 [SUCCESS] 2g.CentOS.com
Use the following command to recursively copy folders to multiple remote servers.
# pscp.pssh-h server-list.txt-r / home/daygeek/2g/shell-script/ / opt/backup [1] 18:51:31 [SUCCESS] 2g.Debian.com [2] 18:51:31 [SUCCESS] 2g.CentOS.com, have you mastered how the Linux system copies files and folders to a remote server? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.