In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the wget command to download files in Linux, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Example 1: download a single file
# wget http://mirror.nbrc.ac.in/CentOS/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso
This command downloads the CentOS 7 ISO file to the user's current working directory.
Example 2: continue to download files in segments
There are always scenarios where the Internet is disconnected when we start downloading a large file. In that case, we can use the'- c 'option of the wget command to resume the download from the breakpoint.
# wget-c http://mirror.nbrc.ac.in/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso
Example 3: download files in the background
We can have it download the file in the background by using the'- b 'option in the wget command.
Linuxtechi@localhost:~$ wget-b http://mirror.nbrc.ac.in/centos/7.0.1406/isos/x86_64/
CentOS-7.0-1406-x86_64-DVD.iso
Continuingin background, pid 4505.
Output will be written to 'wget-log'.
As we saw above, the download process is captured in the 'wget-log' file in the user's current directory.
Linuxtechi@localhost:~$ tail-f wget-log
2300K. . . .0% 48.1K18h6m
2350K. . . .0% 53.7K18h9m
2400K. . . .0% 52.1K18h23m
2450K. . . .0% 58.3K18h24m
2500K. . . .0% 63.6K18h24m
2550K. . . .0% 63.4K18h23m
2600K. . . .0% 72.8K18h20m
2650K. . . .0% 59.8K18h21m
2700K. . . .0% 52.8K18h24m
2750K. . . .0% 58.4K18h25m
2800K. . . .0% 58.2K18h26m
2850K. . . .0% 52.2K18h30m
Example 4: limit the download rate
By default, the wget command tries to download at full speed, but sometimes you may be using the shared Internet, so if you try to download large files using wget, it will slow down other users' networks. At this point, you can prevent this from happening if you use the'- limit-rate' option to limit the download rate.
# wget-- limit-rate=100k http://mirror.nbrc.ac.in/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso
In the above example, the download rate is limited to 100k.
Example 5: use the'- i' option to download multiple files
If you want to use the wget command to download multiple files, first create a text file and add all the URL to it.
# cat download-list.txt
Url1
Url2
Url3
Url4
Now, issue the following command:
# wget-I download-list.txt
Example 6: increase the number of retries
We can use the'- tries' option to increase the number of retries. By default, the wget command retries 20 times until the download is successful.
This option is useful when there is a problem with your Internet connection when you download a large file, because in that case, it increases the chances of download failure.
# wget-- tries=75 http://mirror.nbrc.ac.in/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso
Example 7: use the-o option to redirect wget logs to a file
We can use the'- o 'option to redirect the log of the wget command to a log file.
# wget-o download.log http://mirror.nbrc.ac.in/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso
The above command creates a download.log file in the user's current directory.
Example 8: download the entire website for local viewing
# wget-- mirror-p-- convert-links-P / "Local-Folder" website-url
Given that
-mirror: enable the option for mirroring.
-p: download all necessary files that correctly display the specified HTML page.
-convert-links: after the download is complete, convert the links in the document for local viewing.
-P. / Local-Folder: save all files and directories to the specified directory.
Example 9: file types are rejected during download
When you are about to download the entire site, we can use the'- reject' option to force wget not to download images.
# wget-reject=png Website-To-Be-Downloaded
Example 10: use wget-Q to set download quota
We can use the'- Q' option to force the wget command to exit the download when the download size exceeds a certain size.
# wget-Q10m-I download-list.txt
Note that quotas do not affect the download of individual files. So, if you specify wget-Q10m ftp://wuarchive.wustl.edu/ls-lR.gz recorder lsmerlR.gz, all of its contents will be downloaded. This is also true when downloading multiple URL specified by the command line. However, it is worth using when recursive or retrieved from an input file. Therefore, you can safely enter 'wget-Q10m-I download-list.txt',' and the download will exit when the quota is exceeded.
Example 11: download files from a password-protected website
# wget-ftp-user= "user-name"-ftp-password= "password" Download-URL
Another way to specify a user name and password is in URL.
Either way, your password is exposed to those who run the "ps" command. To prevent passwords from being seen, save them to .wgetrc or .netrc and use "chmod" to set the appropriate permissions to protect these files from other users. If passwords are really important, don't walk away while they are still in the file, edit the file after Wget starts downloading, or delete them.
The above is how to use the wget command to download files in Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow 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: 222
*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.