In this tutorial, you will learn how to fix apt command not found error.
Apt is the default package manager for Ubuntu, and debian based distros. Apt can be used to manage packages on your system, with apt you can install, update, upgrade and remove packages easily from your system.
Apt is included by default on Debian based distros, such as Ubuntu or Debian, so you don't need to install it manually in order to use it. However, there are cases when apt package manager gets corrupted or not working correctly, which means you won't be able to install or remove packages on your machine.
For example when you run apt, you may get the error "apt command not found"
This error happens when system doesn't recognize the command you are trying to run.
Fix apt command not found
Step 1 - Check if apt is installed
First thing that you need to do is checking if apt is installed on your system. To do so, you can check the version of apt that is installed on your system.
apt --version
Now, if apt is installed on your machine, the command above will show you which version of apt is installed. If apt is not installed, the command above won't show anything.
For example, in our case apt is not installed.
Step 2 - Install apt
If apt is not installed on your machine, you need to install it manually, because you can't use apt to install apt.
Installing apt manually, can be done easily via the apt deb binary.
To install apt manually, you need to download the deb binary file from the official Ubuntu repository. You can use a tool like wget or curl to download it.
1) Download the apt package apt_2.4.5_amd64.deb
using wget.
wget -0 apt-2.4.5-amd64.deb --quiet http://mirrors.kernel.org/ubuntu/pool/main/a/apt/apt_2.4.5_amd64.deb
2) Next, proceed to install apt-2.4.5-amd64.deb
binary that you downloaded, since there's no package manager installed on your system, you need to install apt via dpkg
command.
sudo dpkg -i apt-2.4.5-amd64.deb
Once you run the command above, you will be asked to authenticate, proceed to authenticate in order to install apt.
Step 3 - Verify that error is fixed
Once apt is installed on your machine, you should be able to use it and update your system.
sudo apt update
Conclusion
In this tutorial, you learned how to fix "apt command not found" error by installing apt tool manually.