How to Install wget on Debian 12?


Wget is a (command-line) utility that can download any type of file from the internet. It supports several protocols, such as FTP, HTTPS, and HTTP. Wget can also resume interrupted downloads, making it useful for downloading large files or updating packages. It can also follow links, resume interrupted downloads, and mirror websites. By default, the wget utility is pre-installed on Debian distributions such as Debian 12.

This guide will explain different methods to install wget on Debian 12. Users can pick the one that suits/matches their preferences. Let’s see the supported content of the article.

Let’s start with the installation.

How to Install wget on Debian 12?

If users find, a “Bash: wget command not found” error, install the “wget” utility by following the below methods:

Let’s begin with the easy one.

Method 1: Install wget on Debian 12 from the Official Debian Repositories

The easiest and most recommended way to install wget on Debian 12 is to use the apt package manager. It ensures users get the latest stable version of wget that is compatible with your system. To install wget from the official Debian repositories, follow these steps:

Step 1: Update Packages Index

To install wget on Debian 12, you need to have sudo privileges or be logged in as the root user. You can use the following command to update the package index:

sudo apt update

Step 2: Install wget

To install wget on Debian 12, use the “wget” utility with the “apt” command as below:

sudo apt install wget

It automatically installs Wget and any required dependencies.

Step 3: Verify wget Installation

Users can verify that wget is installed by checking its version as below:

wget --version

Remove/Uninstall wget

To remove/uninstall wget from Debian 12, use the “autoremove” utility by mentioning the “wget” as below:

sudo apt autoremove wget

That is all the installation of wget from the default repository.

Method 2: Install wget on Debian 12 from the Source Code

To install wget from the source code, users need to have some prerequisites installed on your Debian 12 system. Let’s follow the below steps for the complete installation:

Step 1: Install Dependencies

These include gcc, make, libssl-dev, and zlib1g-dev. You can install them with the following command:

sudo apt update
sudo apt install gcc make libssl-dev zlib1g-dev

Step 2: Download wget Source Code

Next, download the source code of wget from its official website. It downloads the latest stable release.

Step 3: Extract to a Directory

After downloading the source code, navigate to the “Downloads” directory. After that, users need to extract it to the same directory with the “tar” command:

cd Downloads
tar -xvf wget-1.21.4.tar.gz

Step 4: Configure Makefile

Now, move to the extracted directory and configure the make file using the “./configure” command. This script checks the system for the required libraries and tools, and generates a Makefile for compiling wget:

cd wget-1.21.4
./configure

Note: If users find any error, execute the “sudo apt install libgnutls28-dev” command or use the “./configure –prefix=/usr” command.

Step 5: Compile the Source Code

Now, it’s time for the compilation of source code via the below command:

make

Step 6: Install wget

Finally, install the wget using the “make install” command below:

sudo make install

Verification

After the installation, users can verify the wget is installed correctly via the “version” utility as below:

wget --version

That is all from this section.

Method 3: Install wget on Debian 12 from the .deb Package

The .deb package is a binary file that contains the wget program and its dependencies. To install wget from the .deb package, follow these steps:

Step 1: Download wget

Users can download wget from the official Debian repository or a mirror site.

Step 2: Navigate to Downloaded Directory

Then, open a Debian terminal and move to the folder/directory where users downloaded the .deb package:

cd Downloads
ls

Step 3: Install wget

Run the following command to install wget and its dependencies by specifying the package name “wget_1.21.3-1”:

sudo dpkg -i wget_1.21.3-1ubuntu1_amd64.deb

Note: If you encounter any errors or missing dependencies, run the following command to fix them:

sudo apt install

Step 4: Verification wget

Verify that wget is installed by running:

wget --version

You have successfully installed wget on Debian 12 from the .deb package. You can now use wget to download files from the internet with various options and features.

How to Use wget on Debian 12?

The wget command supports HTTP, HTTPS, and FTP protocols, and can also download files recursively, in the background, and with limited bandwidth.

To use Wget, specify the file URL or directory that users require to download. Users can also use various options to customize the download process. Here are some examples of how to use wget on Debian:

Example 1: Download Single File

To download a single file and save it in the current directory, use the “wget” command by mentioning the URL:

wget https://ftp.gnu.org/gnu/wget/wget-1.21.4.tar.gz

Example 2: Download Single File (Different Name)

To download a single file and save it under a different name, use “wget” with the “O” flag by mentioning the URL:

wget -O new-file.zip https://sample-videos.com/zip/10mb.zip

Example 3: Download a Single File (Save in a Specific Directory)

To download a single file and save it in a specific directory, use the “wget” command with the “P” flag:

wget -P /home/debian/Downloads https://sample-videos.com/zip/10mb.zip

Example 4: Download Multiple Files

To download multiple files from a list of URLs in a text file, use the “wget” command with the “i” flag by mentioning the filename as below:

wget -i urls.txt

Example 5: Download Entire Website

To download an entire website recursively and mirror it locally, execute the “wget” command with the “m” option by mentioning the URL:

wget -m http://linuxgenie.net/

Example 6: Download Files and Log the Output

To download files in the background and log the output to a file, use the “wget” command by mentioning the URL:

wget -b -o log.txt https://sample-videos.com/zip/10mb.zip

Example 7: Limit the Download Speed

To limit the download speed, use the “limit-rate” utility and assign to the 100 KB/s as below:

wget --limit-rate=100k https://sample-videos.com/zip/10mb.zip

For more information and options, check the wget manual page by typing the “man wget” command or visit the following web pages.

Conclusion

Wget is a popular CLI tool for downloading as well as updating files from the web/internet. To install wget on Debian 12, update the packages list, and install wget using the “sudo apt install wget” command. In addition, confirm the wget installation via the “wget –version” command. Alternatively, use the “.deb Package” and “Source File” to download the latest version of wget. This article has explained different methods to install as well as use the wget utility on Debian 12.

 

Print Friendly, PDF & Email
Categories