Are you a Linux user? If yes then you must have gotten the error “apt-get: command not found” at some point on your Linux PC or server. But there are many ways to avoid this error.
In this article, we will tell you some easy ways by which you will be able to fix APT-GET Command Not Found error.
What is the sudo apt-get command?
Users of Linux systems can install, update, and delete the software from their computers using APT, a command-line (CLI) tool. The user-friendliness of this tool makes it simple for users to maintain their software updated. The main command of APT, apt-get, is capable of carrying out most of its functions.
The most common apt-get commands are as follows:
- sudo apt-get install (to install a package)
- sudo apt-get remove (package removal)
- sudo apt-get update (for updating a package)
- sudo apt-get upgrade (for upgrading a package)
- apt-get help (to know more about a command )
Here, sudo is used to provide you with superuser security privileges.
Reason Behind This Error
Before solving the apt-get command not found error, let us tell you what the apt-get command not found error is.
This apt-get command not found error tries to tell the user that the system is not able to access the apt-get path.
There are two main reasons that cause this error to occur:
- Installing and using the apt-get tool in Ubuntu gets difficult because the apt-get command is not available in the Standard Installation of Ubuntu.
- The apt-get command uses the apt package manager to install software, which becomes a problem for those whose systems are running on older Linux distributions.
How to Fix the apt-get command not found?
Below, we have explained some solutions that can solve the “apt-get command not found” error:
1. Use the correct Native Package Manager
First of all, you need to know which Linux distro you are using. If you are buying a Linux distro other than Debian, then this will do it for you. You will have to do it according to your system package manager. The list of different package managers with their compatible Linux distros is listed here.
|Package Managers||Linux Distributions|
|Red Hat Linux, Fedora, Cent OS|
|Versions from Fedora 18|
Check on Which Operating System Your System is Running.
You have to check this because the apt-get command supports only some operating systems such as Ubuntu, Debian, Mint, and Kali Linux.
If your system does not run in any of these operating systems then the apt-get command will not run in your system.
So first check on which operating system your system is running.
To check on which operating system your system is running, run the cat command and type “cat /etc/*-release” and press enter.
By doing this, you will get all the details of your system and you will also get to know whether your system is running in those operating systems that support the apt-get command.
2. Manually Reinstall apt-get
The most common reason for the sudo apt-Get command not found error is if it is not installed. To reinstall the apt packages perform these steps:
- Go to this link and search for the latest apt package.
In this scenario, go to http://us.archive.ubuntu.com/ubuntu/. and look under “/pool/main/a/apt/” for a list of.deb packages. Choose the option that best fits your architecture (and64/i386).
- After it has finished downloading, use the following command to install the apt DEB file:
sudo dpkg -i /path/to/apt_deb_file.deb
Remember to substitute the path to the file you just downloaded for “/path/to/apt deb file.deb.”
Read Also: How To Easily Rename a File in Linux
Check apt path for its binary
The error “apt-get: command not found” means the system cannot access apt-get at its path. Manually confirming that the path is present would be the obvious solution to this problem.
To find out where the system anticipates the apt-get binary to be, type the following command into the terminal: locate apt-get
The output that appears next should resemble the one below or contain the following string: /usr/bin/apt-get
The “apt” package is not installed if the command produces no output. It requires manual installation using a.deb file.
Apt-Get Command not Found on macOS
macOS, by default, doesn’t use the APT package manager. In fact, the OS doesn’t have a default package manager at all. However, there is a hugely popular apt-get alternative for macOS called Homebrew.
Below is how you would 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)”
- 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.
brew install <package name>
Run The Environment Variables
Try the following command if the sudo apt-get command not found error persists: “/$[YOURUSER]/.bashrc.”
The next step is to run the program “sudo /usr/bin/apt-get update.”
Check to see if the issue has been resolved after completing the previous steps. If not, try again using a root account and repeat the previous procedures. Try executing the following command if you’re having issues: “sudo search / -name ‘apt-get”
Try To Set The Software-Properties-Common Plan
Open “Terminal” and enter the command “sudo apt-get install software-properties-common” to get started. then click Enter.
Wait until the procedure is complete.
Use the command “sudo apt-get mount python-software-properties” for previous versions of Ubuntu.
apt-get: command not found in GCP/Google Cloud
Users have complained in several web forums about having trouble using apt in Google Cloud Platform virtual machines.
GCP isn’t at fault in this instance. You can use apt immediately if you selected Ubuntu as your preferred image while creating your virtual machine. There are a few reasons why this might be the case.
- When establishing the instance in Cloud Console, you might have selected the Containers checkbox. When the Containers checkbox is selected in the instance creation window, a slimmed-down version of the Debian/Ubuntu family operating system will take precedence over the boot disk option. The container-optimized OS has been stripped of apt to minimize system overhead.
- Debian/Ubuntu wasn’t your choice; something else was made instead.
- You are in an OS environment that is sort of nested and doesn’t, for some reason, come with apt preinstalled.
apt-get: command not found in AWS
A typical problem for AWS users that run Amazon Linux images on their servers is “apt-get: command not found.” The truth is that RHEL and CentOS are the two foundations on which Amazon Linux is built. The RHEL distribution family prefers yum as their package manager of choice over apt.
Most of the time, you can test substituting apt or apt-get with yum to see if it succeeds when installing a common piece of software. For instance, you might attempt to install python3 rather than apt install python3. Most of the time, it ought to function.
Reinstall Operating System on your Computer
The solution to this problem is to reinstall the operating system, which will cause the apt-get command to be available again. This way, you can install a new version of the operating system, and your software will work again.
We hope that this tutorial will enable you to quickly and successfully resolve the issue of the apt-get: command not found error. Please let us know about any errors you see or suggestions you have in the comment box below and Please Like And Share this article.
Frequently asked questions:
What is the cause of apt-get: command not found?
When you install packages from the internet or installed them directly on your computer. In this case, you will need to ensure that the package is located in a folder that has been created by apt-get.
How can I reinstall the OS to fix the apt-get: command not found?
How to check Linux distribution?
How do I fix apt-get install?
Press Ctrl + Alt + T to open the terminal, then type sudo apt —fix-missing update.
sudo apt update will update your system’s package list from the available sources.
Use the -f switch to forcibly install the broken packages at this point.