In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the Linux command line to download files", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use the Linux command line to download files"!
The Linux command line provides more flexibility and control than GUI. Many people prefer the command line to GUI because it is easier to use and faster than GUI. Using the command line makes it easier to automate tasks with one line. In addition, it uses fewer resources than GUI.
Downloading files is a daily task, usually performed on a daily basis, including file types such as ZIP,TAR,ISO,PNG. You can use the command line terminal to perform this task easily and quickly. Just use the keyboard. So today, I'll show you how to download files using the command line in Linux. There are usually two known ways to do this, even with the wget and curl tools. For this article, I will use Ubuntu 20.04 LTS to describe the process. But the same command can be run on other Linux distributions, such as Debian,Gentoo and CentOS.
Download files using Curl
Curl can be used to transfer data over a variety of protocols. It uses Curl to support many protocols, including HTTP, HTTPS, FTP, TFTP, TELNET,SCP and so on. You can download any remote file. It also supports pause and resume functions.
First, you need to install curl.
Install curl
Start the command line application in the Ubuntu terminal by pressing Ctrl + Alt + T. Then enter the following command to install curl using sudo.
Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt install curl
Enter the password when prompted for the password of [sudo] linuxmi.
After the installation is complete, enter the following command to download the file.
Download and save the file using the source file name
To save the file on a remote server with the same name as the original source file, use-O (uppercase O), and then use curl, as follows:
$curl-O [URL]
In addition to-O, you can also specify "- remote-name", as shown below. Both work on the same principle.
Download and save the file under a different name
If you want to download the file and save it to a different name than the file name on the remote server, use-o (lowercase o), as shown below. This is useful when the remote URL does not include a file name in the URL, as shown in the following example.
$curl-o [filename] [URL]
[filename] is the new name of the output file.
Curl-remote-name https://github.com/chrishunt/color-schemes/archive/master.zip curl-o linuxmi https://github.com/chrishunt/color-schemes/archive/master.zip downloads multiple files
To download multiple files, enter the command using the following syntax:
$curl-O [URL1]-O [URL2]
Download files from the FTP server
To download a file from a FTP server, enter the command using the following syntax:
$curl-O ftp://ftp.linuxmi.com/www.linuxmi.com.zip
To download files from a user-authenticated FTP server, use the following syntax:
$curl-u [ftp_user]: [ftp_passwd]-O [ftp_URL]
Pause and resume download
When downloading a file, you can pause it manually using Ctrl + C, or sometimes it will be automatically interrupted and stopped for some reason, and you can restore it. Navigate to the directory where you previously downloaded the file, and enter the command using the following syntax:
$curl-c [options] [URL]
Download files using Wget
Using wget, you can download files and content from Web and FTP servers. Wget is a combination of www and get. It supports protocols such as FTP,SFTP,HTTP and HTTPS. It also supports recursive downloads. This feature is useful if you want to download the entire site for offline viewing or to generate a backup of a static site. In addition, you can use it to retrieve content and files from various Web servers.
Install wget
Start the command line application in the Ubuntu terminal by pressing Ctrl + Alt + T. Then enter the following command to install wget using sudo.
Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt install wget
When prompted for a password, enter the sudo password.
Download a file or web page using wget
To download a file or web page, open the terminal and enter the command in the following syntax:
$wget [URL]
To save a single web page, enter the command using the following syntax:
$wget [URL]
Download a file with another name
If the name of the download and save file is different from the name of the original remote file, use-O (uppercase O), as shown below. This is useful for you, especially if you download a web page that is automatically saved with the name "index.html".
To download a file with a different name, enter the command using the following syntax:
$wget-O [file name] [URL]
Download files through FTP
To download a file from a FTP server, type the command using the following syntax:
$wget [ftp_link]
To download files from a user-authenticated FTP server, use the following syntax:
$wget-u [ftp_user]: [ftp_passwd]-O [ftp_URL] Recursive download file
You can use the recursive download feature to download everything in a specified directory, whether it's a website or a FTP site. To use the recursive download feature, enter the command using the following syntax:
$wget-r [URL]
Download multiple files
You can download multiple files using wget. Create a text file with a list of files URL, and then download the list using the wget command with the following syntax.
$wget-I [filename.txt]
For example, I have a text file called "linuxmi.txt" with two URL lists to download using wget. You can see the contents of my text file in the following figure.
I will download the file links contained in the text file using the following command:
$wget-I linuxmi.txt
Use the file containing the URL as the download list
You will see that it is downloading two links one by one.
Pause and resume download
You can press Ctrl + C to pause the download. To resume the paused download, change to the directory where you previously downloaded the file and use the-c option after wget, as shown in the following syntax:
$wget-c filename.zip
Using the above command, you will notice that the download has resumed from the paused location.
Summary
In this article, we discussed the basic usage of two command-line methods under Linux, which you can use to download files. One thing to note is that if you do not specify a directory when you download the file, the file will be downloaded to the current directory you are using.
Thank you for your reading, the above is the content of "how to use Linux command line to download files", after the study of this article, I believe you have a deeper understanding of how to use Linux command line to download files, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.