How to Fix the “apt-get command not found” Message on Linux and Mac

[ad_1]

The “apt-get command not found” error can sometimes leave a Linux user dumbfounded. It could happen to servers and Mac PCs too.

Do not think this issue is unique to your system as many other users have experienced this error. In fact, many others might encounter it sooner or later on their computers or servers that run on Linux, especially those that don’t support Debian yet.

This troubleshooting guide specifically addresses the “apt-get command not found” error. It explores its usual causes and how to fix them, as well as other pertinent information about APT. 

What is the APT Package Manager?

The APT Package Manager, or Advanced Packaging Tool, is a package management system used on Linux systems. It is responsible for installing, updating, and removing software packages on the system. 

APT is used to manage packages that are stored in a central repository, which can be accessed and downloaded from the internet or a local network. It uses a command line interface, which allows users to type in commands to perform specific tasks, like the ones mentioned above.

APT provides sets of tools for package management of Debian-based systems and their derivatives like Linux Mint and Ubuntu. It includes apt-get and apt-cache.

sudo apt update - solving apt-get command not found error

One of the main advantages of using APT is its ability to automatically resolve dependencies. This means when you install a package, APT will automatically install any other prerequisite packages. This is to ensure that the one you installed will function properly. 

In other words, it streamlines the installation process and ensures that all necessary packages are installed.

Alternatives for Other Systems

There are several alternatives to APT Package Manager for non-Linux or Mac systems: 

1. Chocolatey Package Manager for Windows

This package manager allows users to install, update, and manage software packages from a command-line interface. It supports a wide range of software packages and is easy to use, making it a popular choice for Windows users.

Chocolatey software management package

One of the main benefits of using Chocolatey is that it simplifies the process of installing and updating software on Windows. 

Instead of manually downloading and installing software from various websites, you can simply use the Chocolatey command line tool to search for, install, and update packages. This can save a lot of time and effort, particularly for users who frequently install or update multiple software packages.

Another popular command line utility for Windows, especially in network management for large organizations is the GPUpdate Force. If you want to know more about it, we wrote an in-depth overview of this utility, as well.

2. Homebrew Package Manager for Mac

The Homebrew Package Manager for Mac is a command-line utility that allows users to install and manage open-source software packages on their Mac. 

It was developed by Max Howell and has become popular for Mac users looking to install and manage third-party software packages that are unavailable through Apple’s App Store.

homebrew package manager for macOS and Linux

To use Homebrew, users must first install the package manager by running a command in the Terminal. 

Once installed, users can use the “brew” command to search for and install packages from a central repository called the Homebrew Formula Library. This library contains thousands of packages that can be easily installed with a single command.

3. NuGet Package Manager for .NET Developers

The NuGet Package Manager is a free, open-source package management system for .NET developers. It allows developers to easily install, update, and manage libraries and dependencies for their .NET projects.

NuGet package manager for .NET developers

NuGet uses a central repository called the NuGet Gallery, which contains over 100,000 packages that are available for download. These packages contain code libraries, tools, and other resources you can use in a .NET project.

To use the NuGet Package Manager, developers can use the NuGet command-line interface or the NuGet Package Manager UI in Visual Studio. They can search for and install packages directly from the NuGet Gallery, or they can create and publish their own packages in the repository.

Reasons Why the “apt-get command” is Missing

There are a few reasons why the apt-get command may be missing on your system. To fix the “apt-get command not found” error message, you need to verify that the reasons outlined below are not causing the apt-get command issues. 

You can do that by following the step-by-step solutions listed in the ‘How to Fix’ section of this article.

1. APT Package Manager is Not Installed

Even if you have a Debian-based system, if the APT Package Manager is not installed on your system, then naturally the apt-get command will not be available to you. 

Presently, the APT Package Manager is installed by default on Debian-based systems (Ubuntu, Linux Mint, Kali Linux, and Parrot OS), so if you are using one of these distributions, it should already be installed. 

If it’s not installed, then you’ve either removed APT from your system or are using a distribution that does not support APT.

This is quite similar to when you’re working on Javascript, you would need an npm package manager to interpret Node.js. Without one installed, you might encounter the error message: “npm command not found”. But, that is a different topic for discussion. 

2. APT Package Manager Has Been Manually Removed

Another possible reason is that the APT command has been removed or unlinked from your system. This could happen if you have manually removed the APT package or if you used a command such as “apt-get purge” to remove all traces of APT from your system.

3. APT Package Manager Not in Path

It is also possible that the APT get command is not in your system’s PATH. 

The PATH is a list of directories that the operating system searches when you enter a command. If the apt-get command is not in the PATH, then it will not be recognized by the system.

To fix this issue, you can try re-installing the APT package manager, thereby adding the apt-get command back to your system. It could also add the directory containing the apt-get command to your PATH.

4. The apt-get Command is Not Available on Your Distribution

The apt-get command is only compatible with Debian, Ubuntu, and their derivatives (Linux Mint, Kali Linux, and Parrot OS). It will not work on rpm-based operating systems like Fedora, RHEL, and CentOS. 

If you are using an rpm-based OS, you may see the “apt-get command not found” error message when you try to use that command. Yum is the default package manager for distributions like Fedora, CentOS, and RHEL.

How Does the “apt-get command not found” Message Appear?

The “apt-get command not found” message can appear on Linux distributions (like Ubuntu and Debian) and Mac systems. You can encounter this error message when using bash or sudo. 

1. Using Bash

Bash is a Unix shell and command language that allows users to interact with the operating system through the use of commands. It is commonly used in Linux and macOS operating systems and is often the default shell for users. 

Bash allows users to navigate the file system, execute programs, and perform various other tasks on the command line.

Bash: apt-get: command not found

2. Using Sudo 

Sudo is a command that allows users to execute commands with superuser privileges, also known as root access. This means users can perform tasks that would normally require the highest level of access to the system, such as installing or modifying system files. 

Sudo grants temporary or limited access to certain users rather than giving them permanent root access. It is often used in conjunction with bash, allowing users to execute commands with superuser privileges from the command line.

sudo: apt-get: command not found

How to Fix the “apt-get command not found” Message

1. Check if APT is Installed

Before you go any further, you should check first if APT is installed on your system. If it’s not, then that is the definite cause of the “apt-get command not found” message. 

Note: If you are using a non-Debian distribution, APT is not and can’t be installed. 

You can then move on to the next solution to learn how to install APT back onto your system.

  1. Open a terminal window on your computer. This can usually be done by simultaneously pressing the CTRL + ALT + T keys.
check if APT package manager is installed
  1. In the terminal, type apt –version and press Enter
  1. If the APT Package Manager is installed, you will see a message with the version number of APT. For example:

apt 1.6.8 (amd64)
  1. If you see a message saying that the command was not found or that apt is not installed, this means you don’t have APT in your system.

Alternatively, you can use the locate apt-get command to check if apt-get exists on your system. If this command locates apt-get then the command is, in fact, somewhere on your system.

locate apt-get

2. Install APT Package Manager

Installing APT Package Manager is pretty simple as long as you can locate the compatible version with your distribution. If you need to install APT (because you removed it previously using sudo apt remove apt), you can reinstall the package manager. 

To reinstall APT, follow these steps:

  1. Locate the correct file for your distribution version from the mirrors.kernel.org website. Click on your distribution location in the column on the right-hand side (again, it must be a Debian derivative to install APT).
locate distribution version of APT

If you are using Debian, you can find it here: 

https://mirrors.edge.kernel.org/debian/pool/main/a/apt/

index of debian pool

If you are using Ubuntu, you can find it here: https://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/

  1. Once you find the correct .deb file, use the wget command and the file link to download the .deb file. For example:
wget http://mirrors.edge.kernel.org/ubuntu/pool/main/a/apt/apt_1.6.10_amd64.deb
  1. Install the .deb file using dpkg. Dpkg is a low-level tool for installing Debian packages. The command to install is sudo dpkg -i <package_name>. Continuing our example:
sudo dpkg -i apt_1.6.10_amd64.deb
install sudo dpkg
  1. You may also want to install any packages that may have been affected by the APT Package Manager removal:
sudo apt install apt-utils ubuntu-minimal ubuntu-release-upgrader-gtk ubuntu-desktop update-manager update-notifier update-notifier-common

3. Export PATH

The final solution covered in this section is how to export the directory that contains the APT binary to environment variables. 

If the APT binary directory is not located in the environment variables, then APT Package Manager won’t work correctly. This might be the cause of the ‘apt-get command not found’ message. 

  1. Within the terminal, use the whereis apt command. This will provide APT’s directory location. 
whereis apt
  1. In this case, APT is located within /usr/bin. Now you want to check if /usr/bin (or whatever path you received from whereis apt) is located in environment variables. Use the command echo $PATH:
check the path - solving the apt-get command not found error
  1. Each PATH within environment variables is separated by colons. If /usr/bin/ or whatever path is applicable for your APT is not in this list, you’ll need to add it. You can do this with the export command. In this example, that would be:
export PATH=$PATH:/usr/bin
export PATH
  1. To make this a permanent fix, you need to open and edit the .bashrc file within your home directory using a text editor. 

At the end of the file, you’ll want to add the following line (again with whatever path matches your APT location:

export PATH="$PATH:/usr/bin"
  1. Save the changes to .bashrc and then execute the following command to update the path environment variable:
source .bashrc
source .bashrc

The “apt-get command not found” Error is Fixed!

Let’s recap: The APT Package Manager is a widely used package management system on Linux systems that allows users to install, update, and remove software packages. One of its main benefits is its ability to automatically resolve dependencies when installing packages, streamlining the process, and ensuring that all necessary packages are installed.

There are several alternatives to APT for non-Linux systems, such as Chocolatey for Windows, Homebrew for Mac, and NuGet for .NET developers. 

If the apt-get command is missing on a system, it may be because the APT Package Manager is not installed or because the PATH environment variable is not set correctly. You may also be using the wrong distribution.

These issues can be resolved by following the step-by-step solutions outlined in this troubleshooting article. Hopefully, one of these three solutions will help you resolve the “apt-get command not found” on your Linux or Mac system. 

[ad_2]

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00