To fix the “wget command not found” error in Linux, you should try these three solutions:
- Update package manager and install wget via the Terminal command
sudo apt-get update && sudo apt-get install wgeton your Linux system.
- Download the wget source code, navigate to the directory via Terminal, configure and compile source code, and install wget with
sudo make install.
- Use Alternative tools include cURL and aria2, which can be installed via the Terminal, and files can be downloaded using their respective commands
curl -O <url>and
To use wget effectively in Linux, always check the download file source, use
-i for batch downloads,
-nc to prevent overwriting,
-c to resume interrupted downloads,
-P to specify the download directory,
-q to suppress output, limit bandwidth with
--limit-rate, and be careful with recursive downloading by limiting depth with
Learn more about fixing the “wget command not found” error in Linux and its effective uses in the article below.
The “wget command not found” error on Linux can occur if the wget package is not installed or the command path is not set. It may also not be included in your Linux distribution. However, fixing this error is straightforward, and this article provides a guide to quickly resolve it and continue using the wget command on your Linux system.
How to Fix “wget command not found” Error in 3 Easy Ways
To fix the “wget command not found” error in Linux, use the package manager or compile it from the source. cURL or aria2 are alternative tools that can be used if neither of those options works. Let’s explore these three methods here:
1. Installing wget Using Package Manager
The easiest way to fix the “wget command not found” error is to install wget on your Linux system. To do so, you can use the package manager that comes with your Linux distribution. Here’s the step-by-step process to do it:
- Launch the Terminal and execute the command below to update the package manager and install wget:
sudo apt-get update && sudo apt-get install wget
- Enter your user password if prompted and wait for the installation to complete.
- Finally, you can run the command
which wgetto confirm if wget is installed on your Linux system. This command will display the path to the directory where the wget command is located. Once confirmed, you should no longer encounter the “wget command not found” error.
2. Compiling wget from Source
Another way to install wget and resolve the “wget command not found” error is to compile its code from the source. To do so, follow the steps below:
- Download the wget source code from the official website.
- Navigate to the wget source code directory location using the cd command in the Terminal app.
- Extract the downloaded file by running the following command:
tar -xvf wget-<version>.tar.gz
- Configure the source code with the following command:
- Execute the command below to compile the wget source code:
- Install wget with the following command to fix the “wget command not found” error on your Linux system:
sudo make install
3. Using Alternative Tools to wget
If the above methods don’t fix the “wget command not found” error, try using alternative tools to get wget. Here are some options:
- cURL: cURL is a command-line tool used for transferring data to and from servers. It is similar to wget and can be used as an alternative to it.
- aria2: aria2 is a command-line tool used for downloading files from the internet. It can simultaneously download files from multiple sources, making it faster than wget.
Here’s how to install and use cURL:
- Press Ctrl + Alt + T to open the Terminal app.
- Install cURL by running the following command:
sudo apt-get install curl
- To download a file using cURL, run the following command:
curl -O <url>
Replace <url> with the URL of the file you want to download.
And here’s how to install and use aria2:
- Head to the Terminal window on your Linux system.
- Run the following command to install aria2 on your Linux system :
sudo apt-get install aria2
- To download a file using aria2, run the following command:
Replace <url> with the URL of the file you want to download.
8 Best Practices for Using wget in Linux
While wget can be a powerful and useful tool, it’s important to know how to make the most of it. Here are some best practices for using wget in Linux:
- 🔍 Check the source: Always check the source of the file you’re downloading to ensure it’s legitimate and safe. Don’t download files from untrusted sources or websites you’re unfamiliar with.
- 💾 Use -i for batch downloads: Use the
-ioption to download multiple files from a list. This can save you time and effort if you need to download a large number of files. For instance, you can run
wget -i list.txtif the list exists in a text file.
- 💻 Be Mindful of Bandwidth Usage: Be mindful of bandwidth usage when downloading large files or multiple files at once. This is especially important if you’re on a limited bandwidth connection or if you’re downloading files from a server that’s far away. To limit download speed to 1MB/s, use the
wget --limit-rate=1m http://example.com/file.zipcommand line via Terminal.
- ❌ Use -nc to prevent overwriting: Use the
-ncoption to skip downloading files that are already in the target directory. It lets you prevent overwriting important files and save space on your Linux system. Your command should look like this:
wget -nc http://example.com/file.zip
- ⚠️ Be Caution with Recursive Downloading: Recursive downloading is useful for downloading entire directories or websites. However, it can be resource-intensive and quickly fill up your hard drive if you’re not careful. Use the
-npoption to prevent wget from following links to parent directories and use the
-loptions to limit the depth of recursive downloading. For example, if you want to limit the recursive depth to 2, use the
wget -r -l 2 http://example.com/command.
- ↩️ Use -c to resume interrupted downloads: Use the
-coption to resume downloading a file from where it left off if the download was interrupted for any reason, such as a lost internet connection. Your command would be similar to
wget -c http://example.com/file.zipif you are downloading a file from a URL.
- 🔇 Suppress output with the -q option: Use the
-qoption to suppress output from wget. This can be useful if you’re running wget in a script or automated process and don’t want to clutter the output with unnecessary information. An example of this command is:
wget -q http://example.com/file.zip
- 📂 Use -P to specify the download directory: Use the
-Poption to specify the download directory. This option is helpful when you want to save downloaded files to a particular directory instead of the current working directory. The command syntax would be:
wget -P /path/to/directory http://example.com/file.zip
The “wget command not found” error can be frustrating, but it’s not uncommon. By following the methods outlined in this article, you should be able to fix this error and continue using the wget command on your Linux system. Whether you choose to install wget using the package manager, compile it from source, or use alternative tools, you now know to overcome this error and make the most of the wget command’s powerful functionality.
If you’re interested in learning more about Linux, there are some articles you’ll find super useful. That includes setting the time zone, using multiple ways to monitor memory usage, and exploring the uses of the help command in Linux. By reading these articles and others like them, you’ll become a Linux pro user and take full advantage of its versatile command-line tool. So, keep learning and exploring to master Linux and its full potential.
Frequently Asked Questions
What is wget Command?
wget is a command-line utility used for downloading files from the internet. You can download entire websites or specific files from websites. Here are some common use cases of the wget command:
–Downloading files from a website
–Downloading entire websites for offline browsing
–Retrieving files from FTP or HTTP servers
–Downloading files recursively
Can wget download files recursively from a website?
Yes, wget can download files recursively from a website using the
-r option. This tells wget to follow links and download all files that it finds on the website. However, it’s important to use this feature responsibly and not download more data than you need or overwhelm the website’s servers with too many requests.
Is wget pre-installed in Linux distributions?
While wget is not pre-installed in all Linux distributions, it is widely used and available for download on most of them. One of the reasons why wget is not pre-installed on some Linux distributions is that it is a relatively specialized tool. Not all users need to download files from the command line, so some distributions opt not to include it by default.
How can I check if wget is installed on my system?
To check if wget is installed on your system, open a terminal window and enter the command which wget. If the wget is installed, it will show the path to the wget executable. If it’s not installed, you’ll get an error message saying, “wget command not found.”