Selasa, 31 Maret 2015

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 HTTPHTTPS and FTPWget utility is freely available package and license is under GNU GPL License. This utility can be install any Unix-like Operating 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.

1. Single file download

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

2. Download file with different name

Using -O (uppercase) option, downloads file with different file name. Here we have given wget.zip file name as show below.
# wget -O wget.zip http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz

3. Download multiple file with http and ftp protocol

Here we see how to download multiple files using HTTP and FTP protocol with wget command at ones.
# 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 file

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

5. Resume uncompleted download

In 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 download file without specifying -c optionwget will add .1 extension at the end of file, considering as a fresh download. So, it’s good practice to add -cswitch when you download big files.
# wget -c http://mirrors.hns.net.in/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso

6. Download file with appended .1 in file name

When you start download without -c option wget add .1 at the end of file and start with fresh download. If .1already exist .2 append at the end of file.
# wget http://mirrors.hns.net.in/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso

7. Download files in background

With -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/6.0.5/i386/iso-dvd/debian-6.0.5-i386-DVD-1.iso

8. Restrict download speed limits

With 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/6.0.5/i386/iso-dvd/debian-6.0.5-i386-DVD-1.iso

9. Restricted FTP and HTTP downloads with username and password

With Options –http-user=username–http-password=password & –ftp-user=username–ftp-password=password, you can download password restricted HTTP or FTP sites as shown below.
# wget --http-user=narad --http-password=password http://mirrors.hns.net.in/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso
# wget --ftp-user=narad --ftp-password=password ftp://ftp.iinet.net.au/debian/debian-cd/6.0.5/i386/iso-dvd/debian-6.0.5-i386-DVD-1.iso

10. Find wget version and help

With Options –version and –help you can view version and help as needed.
# wget --version

# wget --help

Tidak ada komentar:

Posting Komentar