Search for:
10 Wget (Linux File Downloader) Command Examples in Linux

10 Wget (Linux File Downloader) Command Examples in Linux &-8211; this Article or News was published on this date:2019-05-28 19:58:01 kindly share it with friends if you find it helpful

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-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.

Linux Wget Command ExamplesLinux Wget Command Examples

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

wget-1.12-1.4.el6.i686

Please install it using YUM command in case wget is not installed already or you can also download binary package at http://ftp.gnu.org/gnu/wget/.

- yum -y install wget

The -y option used here, is to prevent confirmation prompt before installing any package. For more YUM command examples and options read the article on 20 YUM Command Examples for Linux Package Management.

1. Single file download

The 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

--2012-10-02 11:28:30--  http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz
Resolving ftp.gnu.org... 208.118.235.20, 2001:4830:134:3::b
Connecting to ftp.gnu.org|208.118.235.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 446966 (436K) [application/x-gzip]
Saving to: wget-1.5.3.tar.gz
100%[===================================================================================>] 446,966     60.0K/s   in 7.4s
2012-10-02 11:28:38 (58.9 KB/s) - 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

--2012-10-02 11:55:54--  http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz
Resolving ftp.gnu.org... 208.118.235.20, 2001:4830:134:3::b
Connecting to ftp.gnu.org|208.118.235.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 446966 (436K) [application/x-gzip]
Saving to: wget.zip
100%[===================================================================================>] 446,966     60.0K/s   in 7.5s
2012-10-02 11:56:02 (58.5 KB/s) - wget.zip

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

--2012-10-02 12:11:16--  http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz
Resolving ftp.gnu.org... 208.118.235.20, 2001:4830:134:3::b
Connecting to ftp.gnu.org|208.118.235.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 446966 (436K) [application/x-gzip]
Saving to: wget-1.5.3.tar.gz

100%[===================================================================================>] 446,966     56.7K/s   in 7.6s

2012-10-02 12:11:29 (57.1 KB/s) - wget-1.5.3.tar.gz

--2012-10-02 12:11:29--  ftp://ftp.gnu.org/gnu/wget/wget-1.10.1.tar.gz.sig
           => wget-1.10.1.tar.gz.sig

Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /gnu/wget ... done.
==> SIZE wget-1.10.1.tar.gz.sig ... 65
==> PASV ... done.    ==> RETR wget-1.10.1.tar.gz.sig ... done.
Length: 65 (unauthoritative)

100%[===================================================================================>] 65          --.-K/s   in 0s

2012-10-02 12:11:33 (2.66 MB/s) - wget-1.10.1.tar.gz.sig

FINISHED --2012-10-02 12:11:33--
Downloaded: 2 files, 437K in 7.6s (57.1 KB/s)

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.txt under wget directory where we put series of URL’s to download.

- wget -i /wget/tmp.txt

--2012-10-02 12:34:12--  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
Resolving ftp.gnu.org... 208.118.235.20, 2001:4830:134:3::b
Connecting to ftp.gnu.org|208.118.235.20|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 446966 (436K) [application/x-gzip]
Saving to: wget-1.10.1.tar.gz.sig

100%[===================================================================================>] 446,966     35.0K/s   in 10s

2012-10-02 12:34:23 (42.7 KB/s) - wget-1.10.1.tar.gz.sig

--2012-10-02 12:34:23--  http://mirrors.hns.net.in/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso
Resolving mirrors.hns.net.in... 111.91.91.34, 2401:4800::111:91:91:34
Connecting to mirrors.hns.net.in|111.91.91.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1761607680 (1.6G) [application/octet-stream]
Saving to: CentOS-6.3-x86_64-LiveDVD.iso

 45%[==========================================                                          ] 1,262,000   51.6K/s  eta 8h 17m

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 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/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso

--2012-10-02 12:46:57--  http://mirrors.hns.net.in/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso
Resolving mirrors.hns.net.in... 111.91.91.34, 2401:4800::111:91:91:34
Connecting to mirrors.hns.net.in|111.91.91.34|:80... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 1761607680 (1.6G), 1758132697 (1.6G) remaining [application/octet-stream]
Saving to: CentOS-6.3-x86_64-LiveDVD.iso

 51% [=================================================                                  ] 3,877,262   47.0K/s  eta 10h 27m ^

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 .1 already 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

--2012-10-02 12:50:49--  http://mirrors.hns.net.in/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveDVD.iso
Resolving mirrors.hns.net.in... 111.91.91.34, 2401:4800::111:91:91:34
Connecting to mirrors.hns.net.in|111.91.91.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1761607680 (1.6G) [application/octet-stream]
Saving to: CentOS-6.3-x86_64-LiveDVD.iso.1

 18% [==================                                                                 ] 172,436     59.2K/s   

See the example files with .1 extension appended at the end of the file.

- ls -l CentOS*

-rw-r--r--. 1 root root 3877262 Oct  2 12:47 CentOS-6.3-x86_64-LiveDVD.iso
-rw-r--r--. 1 root root  181004 Oct  2 12:50 CentOS-6.3-x86_64-LiveDVD.iso.1

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

Continuing in background, pid 3550.

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

/wget/log.txt: Scheme missing.
--2012-10-02 13:16:21--  ftp://ftp.iinet.net.au/debian/debian-cd/6.0.5/i386/iso-dvd/debian-6.0.5-i386-DVD-1.iso
           => debian-6.0.5-i386-DVD-1.iso
esolving ftp.iinet.net.au... 203.0.178.32
Connecting to ftp.iinet.net.au|203.0.178.32|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /debian/debian-cd/6.0.5/i386/iso-dvd ... done.
==> SIZE debian-6.0.5-i386-DVD-1.iso ... 4691312640
==> PASV ... done.    ==> REST 2825236 ... done.
==> RETR debian-6.0.5-i386-DVD-1.iso ... done.
Length: 4688487404 (4.4G), 4685662168 (4.4G) remaining (unauthoritative)

 0% [                                                                                    ] 3,372,160   35.5K/s  eta 28h 39m

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

In 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.

How to Reset Forgotten Root Password in RHEL/CentOS and Fedora

How to Reset Forgotten Root Password in RHEL/CentOS and Fedora &-8211; this Article or News was published on this date:2019-05-28 19:57:07 kindly share it with friends if you find it helpful

In this post will guide you simple steps to reset forgotten root password in RHEL, CentOS and Fedora Linux with example. There are various ways to reset root password which are.

  1. Booting into single user mode.
  2. Using boot disk and edit passwd file.
  3. Mount drive to another system and change passwd file.
Reset Root PasswordReset Root Password

Reset Forgotten Root Password

Here, in this article we are going to review “Booting into single user mode” option to reset forgotten root password.

Cautious: We urge to take backup of your data and try it out at your own risk.

STEP 1. Boot Computer and Interrupt while booting at GRUB stage hitting ‘arrow‘ keys or “space bar“.

Reset Root PasswordBooting Grub Stage

Booting GRUB Stage

STEP 2. Type ‘a‘ to modify kernel argument. Anytime you can cancel typing ‘ESC‘ key.

Reset Root PasswordModifying Kernel Parameters

Modify Kernel Argument

STEP 3. Append 1 at the end of “rhgb quiet” and press “Enter” key to boot into single user mode.

Reset Root PasswordAppend 1 at the GRUB

Append 1 at the Screen

STEP 4. Type command “runlevel” to know the the runlevel where you are standing. Here “1 S” state that your are in a single user mode.

Reset Root PasswordCommand runlevel

Type Command runlevel

STEP 5. Type ‘passwd‘ command without username and press ‘Enter‘ key in command prompt. It’ll ask to supply new root password and re-type the same password for confirmation. “Your are Done” Congratulation!!!

Reset Root PasswordPasswd Command

Type passwd Command

What if GRUB bootloader is password protected? We’ll cover in our next article, how to protect GRUB with password and reset the same. Stay tuned…

If you find this article is helpful, or you may have some comments or query about it please feel free to contact with us through below comment box.

How to Mount and Unmount an ISO Image in RHEL/CentOS/Fedora and Ubuntu

How to Mount and Unmount an ISO Image in RHEL/CentOS/Fedora and Ubuntu &-8211; this Article or News was published on this date:2019-05-28 19:54:33 kindly share it with friends if you find it helpful

An ISO image or .iso (International Organization for Standardization) file is an archive file that contains a disk image called ISO 9660 file system format. Every ISO file have .ISO extension has defined format name taken from the ISO 9660 file system and specially used with CD/DVD Rom’s. In simple words an iso file is a disk image.

How to mount iso image in linuxHow to mount iso image in linux

mount and unmount iso images in linux

I have seen most of the Linux operating system that we download from the internet are .ISO format. Typically an ISO image contains installation of software’s such as, operating system installation, games installation or any other applications. Sometimes it happens that we need to access files and view content from these ISO images, but without wasting disk space and time in burning them on to CD/DVD.

This article describes how to mount and unmount an ISO image on a Linux Operating system to access and list the content of files.

How to Mount an ISO Image

To mounting an ISO image on Linux (RedHat, CentOS, Fedora or Ubuntu), you must be logged in as “root” user or switch to “sudo” and run the following commands from a terminal to create a mount point.

- mkdir /mnt/iso

OR

$ sudo mkdir /mnt/iso

Once you created mount point, use the “mount” command to mount an iso file called “Fedora-18-i386-DVD.iso“.

- mount -t iso9660 -o loop /home/sfnews/Fedora-18-i386-DVD.iso /mnt/iso/

OR

$ sudo mount -t iso9660 -o loop /home/sfnews/Fedora-18-i386-DVD.iso /mnt/iso/

After the ISO image mounted successfully, go the mounted directory at /mnt/iso and list the content of an ISO image. It will only mount in read-only mode, so none of the files can be modified.

- cd /mnt/iso
- ls -l

You will see the list of files of an ISO image, that we have mounted in the above command. For example, the directory listing of an Fedora-18-i386-DVD.iso image would look like this.

total 16
drwxrwsr-x  3 root 101737 2048 Jan 10 01:00 images
drwxrwsr-x  2 root 101737 2048 Jan 10 01:00 isolinux
drwxrwsr-x  2 root 101737 2048 Jan 10 01:00 LiveOS
drwxrwsr-x 28 root 101737 4096 Jan 10 00:38 Packages
drwxrwsr-x  2 root 101737 4096 Jan 10 00:43 repodata
-r--r--r--  1 root root   1538 Jan 10 01:00 TRANS.TBL

How to Unmount an ISO Image

Simply run the following command from the terminal either “root” or “sudo” to unmount an mounted ISO image.

- umount /mnt/iso

OR

$ sudo umount /mnt/iso
Where Options
  1. -t : This argument is used to indicate the given filesystem type.
  2. ISO 9660 : It describes standard and default filesystem structure to be used on CD/DVD ROMs.
  3. -o : Options are necessary with a -o argument followed by a separated comma string of options.
  4. loop: The loop device is a pseudo-device that often used for mounting CD/DVD ISO image and makes those files accessible as a block device.

Read Also : How to Mount Windows NTFS Partition in Linux

How Do I Access or Mount Windows/USB NTFS Partition in RHEL/CentOS/Fedora

How Do I Access or Mount Windows/USB NTFS Partition in RHEL/CentOS/Fedora &-8211; this Article or News was published on this date:2019-05-28 19:54:29 kindly share it with friends if you find it helpful

Sometimes it may happens in some stage, you may have to access data on a Windows partition, USB device or any similar device. Today most of the modern Linux systems automatically recognize and mount any disks.

However, in some occasions where you may required to configure your system manually to mount ntfs partitions on your Linux system. Specially when you are using dual boot operating environment. Fortunately, this process is not so complicated task its just very fairly straight forward.

How to mount ntfs partition in linuxHow to mount ntfs partition in linux

How to mount Windows NTFS Partition in Linux

This article explains you on how to access or mount Windows XP, Vista NTFS or USB filesystem using the ‘mount‘ command in RHEL/CentOS/Fedora systems.

How to Mount Windows NTFS Partition in Linux

First you need to enable EPEL (Extra Packages for Enterprise Linux) Repository. You may refer the article on how to enable EPEL Repository under RHEL, CentOS and Fedora systems.

To mount any NTFS based filesystem, you need to install a tool called NTFS3G. Before heading up for installation let’s understand NTGS3G.

What is NTFS3G

NTFS3G is an open source cross-platform, stable, GPL licensed, POSIX, NTFS R/W driver used in Linux. It provides safe handling of Windows NTFS file systems viz create, remove, rename, move files, directories, hard links, etc.

Once EPEL is installed and enabled, let’s install ntfs-3g package using the below command with root user.

- yum -y install ntfs-3g
Fuse Install

Next, install and load FUSE driver to mount detected devices with below command. FUSE module is included in the kernel itself in version 2.6.18-164 or newer.

- yum install fuse
- modprobe fuse
Identify NTFS Partition

Once fuse module is loaded, type below command to find out NTFS Partitions in Linux.

- fdisk -l
 Device Boot      Start    End      Blocks   Id  System
/dev/sdb1         1	   21270    7816688   b  W95 FAT32
Mount NTFS partition

First create a mount point to mount the NTFS partition.

- mkdir /mnt/nts

Simply run the following command to mount the partition. Replace sda1 with your actual partition found.

- mount -t ntfs-3g /dev/sda1 /mnt/nts

Once it’s mounted on /mnt/ntfs, you may use regular Linux ls -l command to list the content of mounted filesystem.

[[email protected] ntfs]- ls -l
total 27328
drwx------.  2 root root    16384 Sep  2 19:37 Cert
drwx------. 20 root root    16384 Aug 24  2011 club_application
drwx------.  6 root root    16384 Aug 11 15:37 docs
drwx------.  7 root root    16384 Jul 31  2012 Downloads
drwx------.  2 root root    16384 Dec 10 20:28 images
-rwxr-xr-x.  1 root root    31744 Jan 18 00:29 Material List.doc

If you want to make mount point permanent at the boot time, then simple add the following line at the end of /etc/fstab file. This will remain as permanent.

/dev/sda1    /mnt/usb    ntfs-3g        defaults    0    0
Umount NTFS Partition

Simply, use the following command to unmount the mounted partition.

- umount /mnt/usb

Read Also : How to Mount ISO Images in Linux