Mastering Linux File Transfer Commands

01

Introduction

The Linux basic tutorial has concluded, and you can review the tutorial by clicking: Linux Basic Tutorial. Of course, we will also release more tutorials related to Linux and Bioinformatics in the future, which you can bookmark for continuous updates: Bioinformatics Linux and Server Usage Tips. If you need computing power/servers, you can also click on this series to select your desired device: Shared servers with root accessBioinformatics Analysis Made Easy. This article will guide you through the common file transfer commands in Linux to help you quickly transfer large files. Before learning, make sure you have your server’s IP, username, port, and password ready (if you can connect to the server, you should know this information).

02

Using scp to Transfer Files Between Different Hosts

The difference between scp and cp is that cp is used to copy files to other paths on the local Linux machine. The principle of scp is to log into the Linux server using the ssh protocol and then transfer files. The ssh protocol can log in to Linux using a username and password or a username and key.

The following user, host, port, and xx.pem need to be replaced with specific values.

ssh user@host -p port (requires password input)
ssh user@host -p port -i xx.pem (using key for authentication)
# The command used to copy files with scp is similar to ssh.
scp -P port user@host:/tmp/xiyou.txt . (copy the /tmp/xiyou.txt file from the remote host to the current working directory on the local machine, here "." represents the current directory, requires password input)
scp -r -P port user@host:/tmp/ . (copy the directory from the remote host to the current working directory on the local machine)

scp -i xx.pem -P port user@host:/tmp/xiyou.txt . (authenticate using the key xx.pem, no password input required, the key must be generated in advance)
# Copy a local file to the remote host:
scp -P port user@host:/tmp xiyou.txt

03

Using wget to Download Files from the Internet

# Download the image from the link https://mirrors.tuna.tsinghua.edu.cn/static/img/logo-small-dark.png and save it as tuna.png
wget -O tuna.png "https://mirrors.tuna.tsinghua.edu.cn/static/img/logo-small-dark.png"
ls -la | grep tuna.png
# Download a file without specifying a filename
wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg
ls -la | grep gpg
# View other usage methods for wget parameters
wget --help
# The -c parameter supports resuming downloads, which is very useful for transferring large files
wget -c -O tuna2.png https://mirrors.tuna.tsinghua.edu.cn/static/img/logo-small-dark.png

04

Using mwget

mwget is an upgraded version of wget that supports multithreading and faster download speeds. The installation method is as follows:

# Install compilation dependencies
sudo apt update
sudo apt install build-essential -y
sudo apt upgrade intltool -y
sudo apt install libssl-dev -y

# Compile
git clone https://github.com/rayylee/mwget.git
cd mwget
./configure
sudo make && sudo make install

# View usage methods
mwget --help

mwget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg

05

Using curl to Simulate Browser Access to Websites

curl can also be used to download files, but the experience is not as good as wget.

# Use curl to download the file from the link and save it as tuna3.png
curl -o tuna3.png https://mirrors.tuna.tsinghua.edu.cn/static/img/logo-small-dark.png
# View other usage methods for curl
curl --help

06

Using rsync

Reference link: https://www.ruanyifeng.com/blog/2020/08/rsync.html

# Use port 2234 to copy the local source directory to the remote /destination directory
rsync -av -e 'ssh -p 2234' source/ user@remote_host:/destination

Mastering Linux File Transfer Commands

Contact Us

Mastering Linux File Transfer CommandsMastering Linux File Transfer CommandsLeave a message to receive materials,plug-and-play single-cell analysis image on WeChat[Biomamba_zhushou], making it convenient for everyone to communicate at any time. We have also built a group chat matrix, and everyone is welcome to join the discussion.After reading these articles, you can addtips for beginners in bioinformaticsNo search, no voice

Students who already have the contact information for the bioinformatics basedo not need to add it again

Mastering Linux File Transfer Commands

Mastering Linux File Transfer CommandsYour likes and views are taken seriously as appreciation

Leave a Comment