Friday 25 April 2014

10 Wget (Linux File Downloader) Command Examples in Linux

10 Wget (Linux File Downloader) Command Examples in Linux
In this post we are going to review wget utility which retrieves files from World Wide Web(WWW) using widely used protocols like HTTP, HTTPS and FTP. Wget utility is freely available package and license is under GNU GPL License. This utility can be install any Unix-likeOperating system including Windows and MAC OS. It’s a non-interactive command line tool. Main feature of Wget of it’s robustness. It’s designed in such way so that it works in slow or unstable network connections. Wget automatically start download where it was left off in case of network problem. Also downloads file recursively. It’ll keep trying until file has be retrieved completely.
10 Linux Wget Command Examples

First, check whether wget utility is already installed or not in your Linux box, using following command.
# rpm -qa wget
 



1. Single file downloadThe command will download single file and stores in a current directory. It also shows download progress, size, date and time while downloading.
# wget http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz


2. # wget -O wget.zip http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz

3. wget http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz ftp://ftp.gnu.org/gnu/wget/wget-1.10.1.tar.gz.sig

4. Read URL’s from a fileYou can store number of URL’s in text file and download them with -i option. Below we have created tmp.txt under wget directory where we put series of URL’s to download.
# wget -i /wget/tmp.txt


5. Resume uncompleted downloadIn case of big file download, it may happen sometime to stop download in that case we can resume download the same file where it was left off with -c option. But when you start downloadfile without specifying -c option wget will add .1 extension at the end of file, considering as a fresh download. So, it’s good practice to add -c switch when you download big files.
# wget -c http://mirrors.hns.net.in/centos/6.3/iso...iveDVD.iso


6. Download file with appended .1 in file nameWhen you start download without -c option wget add .1 at the end of file and start with fresh download. If .1 already exist .2 append at the end of file.
# wget http://mirrors.hns.net.in/centos/6.3/iso...iveDVD.iso


 Download files in backgroundWith -b option you can send download in background immediately after download start and logs are written in /wget/log.txt file.
# wget -b /wget/log.txt ftp://ftp.iinet.net.au/debian/debian-cd/...-DVD-1.iso

Continuing in background, pid 3550.8. Restrict download speed limitsWith Option –limit-rate=100k, the download speed limit is restricted to 100k and the logs will be created under /wget/log.txt as shown below.
# wget -c --limit-rate=100k /wget/log.txt ftp://ftp.iinet.net.au/debian/debian-cd/...-DVD-1.iso

# wget --helpIn this article we have covered Linux wget command with options for daily administrative task. Do man wget if you wan to know more about it. Kindly share through our comment box or if we’ve missed out anything, do let us know.

No comments:

Post a Comment