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.
Table of Contents
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.
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.