How to Install wget on Ubuntu

How to Install wget on Ubuntu

When managing a web server or even just working on local development, there are certain tools that are indispensable.

One such tool is wget. wget is a free utility available for Unix-like operating systems, which is used to download files from the internet. It supports downloading via HTTP, HTTPS, and FTP protocols. Whether you’re setting up a new server or just need to download a file quickly without a browser, wget is your go-to solution.

In this guide, we’ll walk you through the steps to install wget on an Ubuntu system. By the end, you’ll have wget set up and ready to use.

Let’s get started.

Step 1: Update Your System

Before installing any new software, it’s always a good practice to update your system’s package list. This ensures you’re getting the latest version and dependencies.

sudo apt update

Step 2: Install wget

Once your system is updated, you can proceed to install wget.

sudo apt install wget

This command will install wget and any necessary dependencies. The system might ask for confirmation; press Y and then Enter to continue.

Step 3: Verify the Installation

After the installation is complete, you can verify that wget was installed correctly.

wget --version

This command should display the version of wget that was installed, confirming that the installation was successful.

For example:

dimitri@webhostinggeeks:~# wget --version
GNU Wget 1.19.4 built on linux-gnu.

-cares +digest -gpgme +https +ipv6 +iri +large-file -metalink +nls
+ntlm +opie +psl +ssl/openssl

Wgetrc:
    /etc/wgetrc (system)
Locale:
    /usr/share/locale
Compile:
    gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/etc/wgetrc"
    -DLOCALEDIR="/usr/share/locale" -I. -I../../src -I../lib
    -I../../lib -Wdate-time -D_FORTIFY_SOURCE=2 -DHAVE_LIBSSL -DNDEBUG
    -g -O2 -fdebug-prefix-map=/build/wget-Xb5Z7Y/wget-1.19.4=.
    -fstack-protector-strong -Wformat -Werror=format-security
    -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall
Link:
    gcc -DHAVE_LIBSSL -DNDEBUG -g -O2
    -fdebug-prefix-map=/build/wget-Xb5Z7Y/wget-1.19.4=.
    -fstack-protector-strong -Wformat -Werror=format-security
    -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall -Wl,-Bsymbolic-functions
    -Wl,-z,relro -Wl,-z,now -lpcre -luuid -lidn2 -lssl -lcrypto -lpsl
    ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a 

Step 4: Basic wget Usage

Now that wget is installed, let’s go over some basic usage:

wget [URL]

Replace [URL] with the link to the file you wish to download. wget will then download the file to your current directory.

See also  How to Uninstall CyberPanel on Ubuntu

Example 1: Specify Download Directory

To download a file to a specific directory:

wget -P /path/to/directory [URL]

Example 2: Download Multiple Files

To download multiple files, you can create a text file with a list of URLs and use:

wget -i /path/to/file.txt

Example 3: Limit Download Speed

To limit the download speed to avoid consuming all available bandwidth:

wget --limit-rate=200k [URL]

This limits the download speed to 200 KB/s.

Example 4: Resume Interrupted Downloads

If a download gets interrupted, you can resume it using:

wget -c [URL]

Example 5: Download in the Background

To download a file in the background:

wget -b [URL]

Example 6: Mirror a Website

To mirror or download an entire website for offline viewing:

wget --mirror --convert-links --adjust-extension --page-requisites --no-parent [website_URL]

Example 7: Set Download Retry Attempts

To specify the number of retries if the download fails:

wget --tries=5 [URL]

This will retry the download 5 times.

See also  How to Uninstall Solr on Ubuntu

Example 8: Download Files with a Specific Extension

To download only files with a specific extension from a website:

wget --recursive --no-parent --no-clobber --accept jpg,jpeg,png [website_URL]

This command will download only .jpg, .jpeg, and .png files.

Example 9: Avoid SSL Certificate Checks

If you’re downloading from a source with an untrusted SSL certificate and want to avoid SSL checks:

wget --no-check-certificate [URL]

Commands Mentioned

  • sudo apt update – Updates the package list for your system.
  • sudo apt install wget – Installs wget and its dependencies.
  • wget –version – Displays the installed version of wget.
  • wget [URL] – Downloads the file from the specified URL.
  • wget -P /path/to/directory [URL] – Specify download directory.
  • wget -i /path/to/file.txt – Download multiple files.
  • wget –limit-rate=200k [URL] – Limit download speed.
  • wget -c [URL] – Resume interrupted downloads.
  • wget -b [URL] – Download in the background.
  • wget –mirror –convert-links –adjust-extension –page-requisites –no-parent [website_URL] – Mirror a website.
  • wget –tries=5 [URL] – Set download retry attempts.
  • wget –recursive –no-parent –no-clobber –accept jpg,jpeg,png [website_URL] – Download files with a specific extension.
  • wget –no-check-certificate [URL] – Avoid SSL certificate checks.

FAQ

  1. Why do I need to update my system before installing wget?

    Updating your system ensures that you have the latest package lists and dependencies, which can prevent potential conflicts and ensure smooth installation of new software, including wget.

  2. Can I use wget to download files from any website?

    Yes, wget can download files from any website that supports HTTP, HTTPS, or FTP. However, ensure you have the necessary permissions and are not violating any terms of service.

  3. Is wget available for other operating systems?

    While wget is primarily designed for Unix-like systems, there are versions and alternatives available for Windows and other operating systems.

  4. How can I specify a different directory for my downloads?

    You can use the ‘-P’ prefix followed by the directory path to specify a different directory for your downloads. For example, ‘wget -P /path/to/directory [URL]’.

  5. Are there any security concerns with using wget?

    As with any tool, it’s essential to use wget responsibly. Avoid downloading files from untrusted sources, and always be cautious of potential security threats. Regularly updating wget ensures you have the latest security patches.

See also  How to Install Java Development Kit (JDK) on Ubuntu

Conclusion

Congratulations! You’ve successfully installed and learned the basics of using wget on Ubuntu.

wget is an incredibly powerful tool with a wide range of functionalities. The examples provided above are just the tip of the iceberg when it comes to what wget can achieve. By mastering these commands, you can streamline and automate various tasks related to file downloads and website management.

Always remember to use wget responsibly and ensure you have the necessary permissions when downloading or mirroring websites.

If you’re in the market for hosting solutions, don’t forget to explore the best dedicated servers and best VPS hosting options. Happy downloading!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *