Why is ‘Sudo: Apt-Get Command Not Found’ on Mac OS

The packaging system “dpkg” helps in installing applications and programs. This dpkg packaging system is mostly used by Debian. Grateful for this; because of this packaging system, the user doesn’t have to build from the source codes.

It requires a tool to integrate with the dpkg packing system. APT (Advanced Package Tool) is the tool required to interact with this dpkg packaging system. However, at times this APT tool tries to misbehave and doesn’t work on macOS and gives you an error “sudo: apt-get: command not found“.

Sudo: Apt-Get Command Not Found

The world of Linux is often considered complex, yet it offers a wide array of powerful tools that enable high levels of customization and control. One such tool is the sudo apt command line utility.

Designed to manage packages on Debian-based systems like Ubuntu, this command is integral for system administrators and savvy users alike.

This article will provide a comprehensive overview of what sudo apt and apt-get are, the reason behind using sudo, how to install these commands, and whether using sudo apt install is safe.

What is Sudo Apt?

The apt command, short for “Advanced Package Tool,” is a package management command-line tool used for installing, upgrading, and managing software on Debian-based Linux systems. When combined with sudo, as in sudo apt, it allows you to execute administrative tasks, such as installing or removing software packages.

What Causes the ‘Sudo: Apt-Get Command Not Found’ Error on Mac OS?

When you are working on the terminal, you might have encountered the term “‘sudo: apt-get command not found”. The “command not found” error appears if that specific application is not available in your system.

If that specific application is not installed in your system, then the terminal will not let you proceed further, and functions related to it will not respond. Although on terminal commands are similar for macOS and Linux.

But that doesn’t mean they both are the same. It consists of a different manager and utilities for installing and managing the packages in Linux and macOS. The APT commands are not available for macOS. The command “apt-get” is used for installing packages on Linux systems.

2 Best Alternatives to APT for macOS 

Debian Linux distributors use APT to download, updating or upgrading applications through Terminal. macOS consist of few alternatives which work similarly to APT. These alternatives have different and better features and work similarly to APT.

Method 1: Installing Homebrew in macOS

Homebrew is a good option for Mac. Its package manager is comfortable to work with. Homebrew is used to install the package in its own directory and store their files into /user/local. Install and run commands in your system by using the following steps.

Steps 1 – At First open Terminal, you will find it in the /Applications/Utilities/

Step 2 – Before running the next code, you must install the Xcode command-line tool in the terminal:

xcode-select –install

Step 3 – Once the Xcode tool installations are done, type and run the following new command to install Homebrew on macOS:

ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Step 4 – It will ask for a password, type the administrator password, and then press Enter.

Step 5 – If you have properly installed the Homebrew, then you will receive the Installation Successful message.

Step 6 – Now install the package by typing the following command using Homebrew:

brew install name

Replace the name in the command with the respective package you want to install in your macOS.

Step 7 – Homebrew will successfully install the package on your macOS.

Method 2: Installing MacPorts in macOS

Macports software is the easiest way of downloading, installing, compiling, and managing open-source software. It will help the user to install any required tools for the given ports.

Just with the help of one single command, you easily download, install, compile, and manage the application. The following steps will help you install the MacPorts in macOS.

Step 1 – Go to the App Store and search for Xcode in the search box. Install the Xcode, but it might take some time due to its large size. Type your username and password to get access to download.

Step 2 – When the Xcode is downloaded, open, and agree to its terms and condition. Otherwise, type the following command in your terminal to agree with the terms and conditions.

sudo xcodebuild –license

Step 3 – Now, open the terminal and type the given command to install Xcode command-line tool:

xcode-select –install

Step 4 – Select the specific MacPorts for your system and download it: MacPorts

Step 5 – Once you have downloaded the specific version, open the downloaded file, and install the given software by following the given instruction. Enter the password if asked.

Step 6 – When the installation is successfully done, restart the terminal and type the given command:

sudo port selfupdate

If the MacPorts are successfully installed in your system, you will get the message ‘Updating MacPorts base sources using rsync‘. However, if you don’t see this message, then you need to reinstall it correctly again.

Step 7 – Lastly, install the specific package by the following command:

sudo port install name

Replace the name in the command with the respective package you want to install in your macOS.

Why is Sudo Used with Apt-Get?

The sudo command stands for “superuser do” and permits you to execute a command as the superuser (or root user), granting administrative privileges.

When you use sudo with apt-get (an older but still widely used variant of apt), you are essentially asking the system to execute package management commands with administrative rights. This is essential for actions that impact system files, like software installations.

How to Install Apt-Get Command

On Debian-based systems like Ubuntu, apt-get is typically pre-installed. However, if for some reason it isn’t, you can install it by executing the following commands:

  1. Update your package list: sudo apt update
  2. Install apt-get: sudo apt install apt

How to Install Apt Command in Linux

The apt command is usually pre-installed on newer Debian-based distributions. If it isn’t, you can install it using apt-get:

  1. Update your package list: sudo apt-get update
  2. Install apt: sudo apt-get install apt

How Do I Run Sudo Apt Update?

Keeping your system updated is crucial for security and performance. To update your package list (which is different from upgrading the packages themselves), you can run:

sudo apt update

This will fetch the latest package information from all configured sources, allowing you to subsequently upgrade your installed packages to their latest versions.

Is Sudo Apt Install Safe?

While sudo apt install is a powerful command, it’s generally considered safe if:

  1. You trust the repository from which you’re installing packages.
  2. You’ve verified the package doesn’t contain malicious code.
  3. You understand the implications of installing a particular package, including dependencies that will also be installed.

However, remember that running any command with sudo should be done with caution, as it gives the command administrative access to your system.


As you can see, the error is quite simple, and the solution is way easier than that. Above were the methods to deal with “sudo: apt-get: command not found“. The methods are quite simple and easy to perform.

Just read it properly and perform accordingly, then you won’t have any issue. You can install any application of your choice, and then you are good to go.

Understanding sudo apt and apt-get provides you with powerful tools for managing your Linux system. These commands offer a straightforward way to keep your software packages updated and secure. While it’s generally safe to use these commands, always exercise caution, especially when executing commands as a superuser.