Syntax:
Option and URL parts are optional for this command. There are many options exist for this command. Some basic start-up options for this command are, -V or –version, -h or –help, -b or –background and -e or –execute. URL will contain the location from where the file will be downloaded. The uses of some common options are explained with examples in this tutorial.
Check `wget` command is installed or not
Run the following command to check the installed version of `wget` command. If the command is not installed before then you will get the error, “ –bash:wget:Command not found”.
The following output shows that wget command of version 1.19.4 is installed on the system.
Install wget command on Ubuntu
Run the following command to install wget command on Ubuntu.
After completing the install, again run the previous command to check the install version of this command. Run the wget command with –h option to display all option details of this command.
Example-1: wget command without any option
The following `wget` command will download the index.html file from the site, linuxhint.com and the file will be stored on the current working directory. ‘ls’ command is used here to check the html file is created or not in the current directory.
$ ls
Example-2: `wget` command with -b option
‘-b’ option is used with `wget` to complete the download in the background. The following command will download, temp.zip file from the site, fahmidasclassroom.com in the background.
Example-3: `wget` command with -c option
‘-c’ option is used with `wget` to complete the partial download. It is mentioned in the beginning of this tutorial that `wget` command has resume capability. If any incomplete download exists in the current directory due to network error or other reason the `wget` will resumes the download to complete the task with ‘-c’ option. The following command will resume the download if the file, xampp-linux-x64-7.2.2-0-installer.run is downloaded partially before. Run the following command to complete the partial download of xampp installer file.
xampp-linux-x64-7.2.2-0-installer.run
Example-4: `wget` command with -O option
-O option is used with `wget` command to store the downloaded file with different name. The following command will download the file, google-chrome-stable_current_amd64.deb with the name, chrome.deb.
google-chrome-stable_current_amd64.deb
Conclusion
The uses of different options of `wget` command are explained in this tutorial by using different examples. If the user facing any problem to use `wget` command for downloading any file, then this tutorial will help them to solve the problems.