Fixing the “apt command not found” Error in Linux

A fix for the infamous "apt command not found" error in Linux.2 min


In this guide, we’ll walk you through the steps to resolve the “apt command not found” error and get your Linux system back on track.

The “apt command not found” Error

Let’s briefly understand why you might encounter this error. The “apt” command is the key application in Debian-based Linux distributions for managing software packages. When you see the “apt command not found” error, it means that the system can’t locate the “apt” command, which is crucial for installing, updating, and removing packages.

Ideally, it should be installed by default. But sometimes, it won’t.

For example, see below.

apt command not found error
apt command not found error

Checking for existing installation

The first step in resolving this issue is to check whether the “apt” package is installed on your system. To do this, open your terminal and run the following command:

dpkg -l | grep apt

If the “apt” package is installed, you should see it listed in the output. If it’s not, you’ll need to install it.

Installing the “apt” package

To install the “apt” package, you can use the “apt-get” command, which should be available on your Debian system by default. Run the following command:

sudo apt-get update
sudo apt-get install apt

This will update your package lists and install the “apt” package. Once the installation is complete, you should be able to use the “apt” command without any issues.

Alternative install

If you are unable to install using any command, you can download the apt<version>.deb file from the below link. Then use dpkg to install the deb file. For example:

sudo dpkg -i apt_2.5.3_amd64.deb

Updating Your System

Now that you have the “apt” package installed, it’s a good practice to update your system’s package list so that you have the latest packages for your system. Run the following command:

sudo apt-get update

This will synchronize your package lists with the Debian repositories.

Testing the “apt” Command

To verify that the “apt” command is now working correctly, simply run:

apt --version

You should see information about the version of the “apt” package, which confirms that it’s installed and functioning properly.

Conclusion

In this article, you learned you how to resolve the “apt command not found” error on your Debian systems. By following these steps, you can ensure that your system has the essential “apt” package installed.

Cheers.


Arindam

Creator and author of debugpoint.com. Connect with me via Telegram, 𝕏 (Twitter), or send us an email.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments