How to install Wget on Ubuntu 24.04

How to install Wget on Ubuntu 24.04

In this blog post, we will guide you on how to install wget on Ubuntu 24.04. Wget is a free and open-source command-line utility primarily written in C that retrieves files from the Internet. Wget can operate in the background and complete downloads after the user logs off. There are many features and capabilities offered by wget, such as protocol support, non-interactive operation, robustness, recursive retrieval, proxy support, flexibility, and timestamping. In this blog post, we will install wget and demonstrate its usage.

Installing wget on Ubuntu 24.04 is a straightforward process that takes a couple of seconds or minutes, depending on the method used. Let’s get started!

Prerequisites

  • A server running Ubuntu 24.04 or any Linux OS
  • User privileges: root or non-root user with sudo privileges

Update the system

Before we start with the installation of wget we need to update the system packages to their latest versions available. To do that, execute the following commands:

sudo apt update -y && sudo apt upgrade -y

Install Wget from Default Repository

Wget by default is included in the Ubuntu 24.04 repository, so installation is only with one command:

sudo apt install wget -y

Once installed, check the version with the command below:

wget --version

You should receive a little bit longer output that prints everything about the wget installation:

root@host:~# wget --version
GNU Wget 1.21.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=3 -DHAVE_LIBSSL -DNDEBUG
-g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
-ffile-prefix-map=/build/wget-LWnKWI/wget-1.21.4=. -flto=auto
-ffat-lto-objects -fstack-protector-strong -fstack-clash-protection
-Wformat -Werror=format-security -fcf-protection
-fdebug-prefix-map=/build/wget-LWnKWI/wget-1.21.4=/usr/src/wget-1.21.4-1ubuntu4.1
-DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall
Link:
gcc -DHAVE_LIBSSL -DNDEBUG -g -O2 -fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer
-ffile-prefix-map=/build/wget-LWnKWI/wget-1.21.4=. -flto=auto
-ffat-lto-objects -fstack-protector-strong -fstack-clash-protection
-Wformat -Werror=format-security -fcf-protection
-fdebug-prefix-map=/build/wget-LWnKWI/wget-1.21.4=/usr/src/wget-1.21.4-1ubuntu4.1
-DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -g -Wall -Wl,-Bsymbolic-functions
-flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -lpcre2-8
-luuid -lidn2 -lssl -lcrypto -lz -lpsl ../lib/libgnu.a

Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic .
Please send bug reports and questions to .

As you can see on the top of the output is the version of the wget command, then the other info, such as the compilation for the specific configuration macros, including paths, optimization levels and security-hardening flags.

See also  How to install Zimbra on Ubuntu 18.04 LTS

This heading was for installing wget from the default Ubuntu 24.04 repository, and that wget version was 1.21.4. If we want to install the latest stable version or some other version, we can do that by installing from source, which will be explained in the next paragraph.

Install Wget from Source

Installing Wget from source is used when we want to install a specific version of Wget.

Before we proceed with the installation process, we will install the build essentials package group that provides the fundamental tools for compiling software, including gcc (the GNU C compiler), make, and other necessary utilities. To install it, execute the following command:

sudo apt-get install build-essential pkg-config libgnutls28-dev gnutls-devel -y

Let’s install the latest stable wget 1.25.0 version. To do that, first, we need to download the wget installation file:

curl -O http://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz

Once downloaded, extract the installation file:

tar -zxvf wget-1.25.0.tar.gz

Enter in the extracted folder and configure the wget:

cd wget-1.25.0/

./configure

Once the configuration is complete next step is the compilation process of the source code:

sudo make

Finally, after the compilation, the last step is the installation process:

sudo make install

Once installed, make a symbolic link:

sudo ln -s /usr/local/bin/wget /usr/bin/wget

Check the installed version:

wget --version

You should receive the following output:

root@host:~/wget-1.25.0# wget --version
GNU Wget 1.25.0 built on linux-gnu.
.
.
.

The Wget Commands

This is the usage and the most used wget commands:

Basic Usage

wget [options] URL

Frequently Used Options & Examples

wget -O myfile.zip https://example.com/file.zip - Save the downloaded file using a custom filename.

wget -P downloads/ https://example.com/file.zip - Save the file into a specified directory.

wget -c https://example.com/largefile.iso - Resume a partially downloaded file (if interrupted).

wget -q https://example.com/file.zip - Quiet mode (suppress output except errors).

wget -b https://example.com/backup.tar.gz - Run the download in the background.

wget -r https://example.com/subdir/ - Download recursively—useful for websites or directories.

wget -r -np https://example.com/subdir/ - When recursive, don’t ascend to parent directories.

wget --mirror https://example.com/ - Shortcut for mirroring a site: recursive, infinite depth, timestamping etc.

wget --wait=2 -r https://example.com/dir/ - Wait N seconds between retrievals (useful when scraping).

More About the Wget Command

If you want to learn more about the wget command in details, you can execute the command below:

man wget

After this, you will get a huge output and everything about the wget in detail:

root@host:~# man wget
WGET(1) GNU Wget WGET(1)

NAME
Wget - The non-interactive network downloader.

SYNOPSIS
wget [option]... [URL]...

DESCRIPTION
GNU Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through
HTTP proxies.

Wget is non-interactive, meaning that it can work in the background, while the user is not logged on. This allows you to start a retrieval and disconnect
from the system, letting Wget finish the work. By contrast, most of the Web browsers require constant user's presence, which can be a great hindrance when
transferring a lot of data.

Wget can follow links in HTML, XHTML, and CSS pages, to create local versions of remote web sites, fully recreating the directory structure of the original
site. This is sometimes referred to as "recursive downloading." While doing that, Wget respects the Robot Exclusion Standard (/robots.txt). Wget can be
instructed to convert the links in downloaded files to point at the local files, for offline viewing.

Wget has been designed for robustness over slow or unstable network connections; if a download fails due to a network problem, it will keep retrying until
the whole file has been retrieved. If the server supports regetting, it will instruct the server to continue the download from where it left off.

OPTIONS
Option Syntax
Since Wget uses GNU getopt to process command-line arguments, every option has a long form along with the short one. Long options are more convenient to
remember, but take time to type. You may freely mix different option styles, or specify options after the command-line arguments. Thus you may write:

wget -r --tries=10 http://fly.srk.fer.hr/ -o log

The space between the option accepting an argument and the argument may be omitted. Instead of -o log you can write -olog.

You may put several options that do not require arguments together, like:

wget -drc

This is completely equivalent to:

wget -d -r -c

Since the options can be specified after the arguments, you may terminate them with --. So the following will try to download URL -x, reporting failure to
log:
.
.
.
.
.
.
.

Bringing it all together

That’s it. You learned how to install Wget on Ubuntu 24.04.

See also  Model-driven observability: Taming alert storms

If you encounter difficulties with this, our Linux administrators will be happy to assist you. Sign up for one of our monthly server management or per-incident server support plans and submit a support ticket.

If you liked this post about installing Wget on Ubuntu 24.04, please share it with your friends or leave a comment below.

The post How to install Wget on Ubuntu 24.04 appeared first on LinuxHostSupport.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply