How to fix 'apt-get: command not found' error in Linux Terminal

If you want to install software on a Debian-based Linux distribution, apt-get is a reliable terminal command. However, sometimes you may get stuck with 'command not found' error as response.

Here's how to handle the "apt-get: command not found" error.

What is apt-get?

The apt-get tool is a command-line package manager for Debian distributions. It allows you to install, update and remove software. Usage of apt-get is as follows:

apt-get [tùy chọn] [lệnh]

So, to install scrot screenshot software, you would use:

apt-get install scrot

Strictly speaking, apt-get is deprecated, which means it is not used for any interactive installation (i.e. pressing Y or N or entering any other command as required). Instead, shorter apt commands (including apt-get commands) are recommended, while apt-get is approved for scripts.

However, if you just need to install some software then both will work.

But what if apt-get doesn't work?

Getting "apt-get: command not found" error on CentOS or RHEL?

The apt-get command usually works without problems, but what if it doesn't?

If you are using a distribution that does not use apt-get then it simply will not work. (For example, this is an easy mistake to make when accessing a remote web server.) To resolve this issue, you must install using the correct package manager.

This could be pacman, zypper, yum or dnf, depending on the Linux distribution.

For example, if you were on a CentOS server and wanted to install software, instead of apt-get (or apt), you would use yum:

 

yum install PACKAGE_NAME

(Where 'PACKAGE_NAME' refers to the package available for installation.)

TipsMake's comparison of apt, yum and dnf explains this further.

Fix 'apt-get: command not found' error on Debian, Ubuntu or Raspberry Pi OS

What if you are using a Debian family distribution like Ubuntu, Pop!_OS or Raspberry Pi OS and encounter the 'apt-get: command not found' error?

Incredibly, this can happen, but what to do to fix the error?

  1. Reinstall the operating system . This is the fastest, least labor-intensive way to solve the problem.
  2. Alternatively, download apt.deb from the Ubuntu website and install with sudo dpkg -i apt_[VERSION].deb (change the filename to match the downloaded file).

Raspberry Pi OS users may find that apt-get install (or sudo apt-get install) does not work. In this case, try apt install instead.

Additionally, if you try apt-get install and get another error (along the lines of "Temporary failure resolving" followed by the server URL) then the problem is with the connection. So, perform the following checks:

  1. Network connections
  2. System clock and date
  3. Use ping to confirm your computer can access any website (e.g. Google)

After making the necessary adjustments, restart your computer and try again.

Other ways to fix 'apt-get: command not found' error

3 other issues can lead to the 'apt-get: command not found' error.

First, did you spell the command correctly? Spelling errors can cause havoc in any text-centric system, from Google search to finding words or phrases on a page. Linux Terminal is no different. Please take the time to make sure you entered 'apt-get' correctly!

Second, maybe your permissions are not enough? Instead of 'apt-get' , try 'sudo apt-get' - the 'command not found' error should now be eliminated.

Finally, if you see a more specific 'sudo: command not found' error appear and you've tried everything above, the problem may actually be sudo, not apt-get.

5 ★ | 1 Vote