APT (Advanced Packaging Tool) is an advanced package management system used by Debian Linux and Linux distributions based on Debian (such as Ubuntu). APT automatically configures, compiles and installs software from many sources such as internet, LAN server, or cdrom. It can greatly simplify process of installing and removing software on Linux system.
APT is not a specific command, but a package management tool set composed of a set of commands. The most commonly used APT commands include apt-get and apt-cache.
Sometimes, you will encounter "apt-get : command not found" error when you try to run apt-get commands either on your own Linux machine or server. This article is going to help you understand a few reasons why it may happen and how to fix it quickly.
Check your Linux distribution
At any moment, there are around a thousand Linux distribution (or Linux distro) exist. They can be configured and optimized for various devices (desktops, laptops, servers, tablets, etc). They can be packaged in a way that suit a community. They can even be developed exclusively to use on an online service (Amazon Linux AMI).
A handful of Linux distro is matured enough to be considered a major distribution. Almost all others will base their release on one of the "major", which have their own preference of standard packages (package manager like apt included).
The bewildering choice and the ever increasing number of Linux distributions can be confusing for those who are new to Linux, so here is a list of the most popular distribution and their package manager of choice.
|Major distribution||Package management system||Package manager|
|Red Hat Linux||RPM-based||yum/dnf|
|openSUSE||RPM-based||zypper (CLI)/YaST (GUI)|
As you can see from the table, only Debian and Ubuntu based distribution use apt by default.
You can check whether your distribution include apt under the hood or not by typing the command
cat /etc/*-release or use one of a few other method.
If you're copying terminal commands from a guide, we suggest you find another which suitable with the Linux distribution you are using. Or better yet, you can use AppImage, a new packaging format which allows applications to run as portable executable files.
"apt-get : command not found" is a common issue for AWS users who are using Amazon Linux images in their servers. You should keep in mind that Amazon Linux is based on CentOS at first, then diverged but it keeps yum as the preferred package manager. So instead of following guides for Ubuntu/Debian with its apt, look for tutorials that was made for Fedora or CentOS.
Check apt path for its binary
"apt-get : command not found" indicates that the system is not able to access apt-get at its path. The logical way to solve this would be manually verify that the path is in place.
Type the following command in the terminal to see where the system expect apt-get binary would be :
The following output should look like the following image or contain this string : /usr/bin/apt-get
If the command returns no output, then you have no “apt” package installed.
You will have to install it manually using a .deb file.
Reinstall apt using dpkg
To do that, you need to grab the corresponding .deb package that was compiled for your OS version. If you're using Ubuntu like me, go to one of its Archive Mirror. In this case, we are going to http://us.archive.ubuntu.com/ubuntu/.
Access /pool/main/a/apt/ path and you'll see a bunch of .deb package. Select the one that is suitable with your architecture (and64/i386)
Once it finishes downloading, you can install apt DEB file by running the following command :
sudo dpkg -i /path/to/apt_deb_file.deb
Remember to replace the
/path/to/apt_deb_file.deb with the path of the file you've just downloaded.
apt-get command not found on macOS
macOS, by default, doesn't use APT package manager. In fact, the OS doesn't have a default package manager at all. However, there is a hugely popular APT alternative for macOS called Homebrew.
Below is how you can install Homebrew on macOS.
First, press the Command + Space key combination to open the Spotlight. Type in "terminal" without the double quotes and hit Enter.
Then, you have to install XCode by running the following command :
Once XCode is successfully installed, you can install Homebrew by running the following one-line command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Please do note that some of the guides you found online may use ruby instead of /bin/bash. Previously, Homebrew installer relies on Ruby as a prerequisites, but now it's been rewritten from scratch and use the built-in bash shell included in macOS. On modern macOS versions, you may encounter "The default interactive shell is now zsh" message, we have a guide on how to fix it that you may want to check out.
Now wait for the installation to finish. You may be prompted for your password during the process.
Sometimes, the Homebrew installer stuck up somewhere and left a corrupted installation. In that case, you may want to read our guide on possible fixes for "brew: command not found".
The command to install a package with Homebrew is similar to its APT counterpart.
Code language: HTML, XML (xml)
<strong>brew install <package name></strong>
Last resort : Reinstall OS
If you've followed the two method above with no luck, then the fastest option in this situation is reinstall the operating system. On a server, you can simply re-imaging the server to have a fresh start.
Remember to backup your data and settings before the reinstall. If you didn't have a tool of your choice to do that, we recommend rclone, a robust and battle-tested solution preferred by open-source community. We did have a guide on how to install rclone on Ubuntu and a few rclone examples to get you started.
We hope that this tutorial helps you solve your problem effectively and quickly. If it does, please consider rate the article below. You might also want to check out our guide on how to fix "Unable to lock the administration directory (/var/lib/dpkg/)" error in apt, which is another common error among Linux newcomers.