The Sudo: apt-get: Command not Found Error usually occurs on macOS and on Linux. It prevents users from executing certain commands that might not be executed because some libraries aren’t available. Therefore, we suggest that you try to check if your Distribution includes APT and follow the solutions that we have listed below.
Fixing the Sudo: apt-get: command not found Error:
Method 1: Using Homebrew In MacOS
Although apt-get is limited to Linux for installation of packages you can use its alternative/equivalent on Mac which is known as “Homebrew”. Follow the steps below in order to do so:
- Press the “Command + Space” keys together to launch the “Spotlight”, type in “Terminal” and press the “Enter” key.
- Then type in the following command and press the “Enter” button:
- Now, to install “Homebrew” type in or copy the following command and press the “Enter” button:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Once the installation is complete, you can now use the following command to install any program/package:
brew install "Name"
Method 2: Using MacPorts On MacOS
This software can be used for the installation and compilation of other packages/software. Proceed with the steps below:
- Launch the “App Store”, type in “Xcode” in the search bar and click “Get”.
- Once installed by follow the on-screen instructions, launch it, and click “Agree”.
- Now, press the “Command + Space” keys together, type in “Terminal” and press “Enter”.
- Next type in the following command and press “Enter” afterwards.
- Now, head over to the MacPorts website from here and download it for your “OS”.
- Launch the file after downloading it and “Install” it by following the on-screen instructions.
- Restart the terminal afterwards and then type in the following:
sudo port selfupdate
- Press “Enter” and now you should be able to use the following command to install any package:
sudo port install name
Method 3: Check If You Have APT Installed
For apt commands to work you must first have its library/package installed. For this, you can check it by heading over to your terminal, and there type the below-mentioned command. Press the “Enter” key afterwards.
If you have the package installed, you will see the following line of code:
Else, it means that you do not have it installed.
Method 4: Reinstalling APT Through dpkg
Follow the steps below to reinstall APT:
- To start with head over to the archive by pressing here.
- Then navigate to the following path:
- Here you will see a lot of files with “.deb format”, choose the one according to your architecture.
- Download it and then install it through the following command:
sudo dpkg -i "Path of File"
- Write the path of your file and then run it on your system. Once done then check to see if the Sudo: apt-get: Command not Found problem got solved.
Method 5: Ensuring That You Are Connected to the AWS
If you are a beginner at RDP/AWS services, then this is the most suitable fix for you. Ensure that you are connected to your AWS Instance, for this head over to the AWS service page, and navigate to your instances. Click “Connect” and follow the on-screen instructions to complete the “SSH”. Once that is done, you should be able to use the apt command in your AWS.
Method 6: Using Correct Package Manager
Based on the distribution being used, you need to use the commands that are supported and appropriate for your machine. For example, if you are using an Amazon Linux, you need to use “yum” instead of “apt-get” as they are based on “Fedora”. macOS by default uses “brew” while Arch Linux uses “packman”, you can also try using “amazon-Linux-extras”.
Method 7: Updating Ubuntu Repositories (Ubuntu and Debian)
To update your databases, proceed with the steps below:
- First, launch your “Terminal”, then type in the following command and press the “Enter” button:
sudo apt-get update
- Wait for the process to be completed and then check if the Sudo: apt-get: Command not Found error got removed.
Method 8: Setting Up Software-properties-common Plan
- Launch your “Terminal”, here type in the following command and press the “Enter” button:
sudo apt-get install software-properties-common
- Now, wait for the process to get completed.
- You can use the following command for older Ubuntu:
sudo apt-get mount python-software-properties
Method 9: Adding In APT
Follow the steps below to install the latest version of Wine on Ubuntu which should resolve the issue:
- Launch your “Terminal”, then type in the following command and hit the “Enter” button afterwards.
sudo apt-add-repository ‘deb https://dl.winehq.org/wine-builds/ubuntu/ bionic major’
- Wait for some time until the process gets completed.
To install LibreOffice:
- Launch your “Terminal”, type in the following commands in sequence, and then press “Enter” afterwards.
sudo add-apt-repository ppa:libreoffice/ppa sudo apt update apt install LibreOffice
- Wait for the process to get completed and then see if the Sudo: apt-get: Command not Found problem still persists or not.
Method 10: For CentOS
Your OS’s default package manager is “Yum” so you can try using the command mentioned below:
sudo yum install <packagename>
But you might encounter an error this way for which you can try downloading the rpmforge-release package using the command below:
wget http://packages.sw.be/rpmforge-release /rpmforge-release-0.5.3-1.e15.rf.i386.rpm
Next, type in the following commands sequence wise to verify and install the package:
sudo rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt rpm -K rpmforge-release-0.5.3-1.e15.rf.i386.rpm sudo rpm -I rpmforge-release-0.5.3-1.e15.rf.i386.rpm
Now you should be able to use the install command that you were getting errors on earlier.
Method 11: Running the Environment Variables
If you are sure that your default package installer command is apt-get and still getting the error code, then you can try running the following command:
Next, execute the following command:
sudo /usr/bin/apt-get update
Now check to see if your issue is resolved, if not, then try with a “root” account and repeat the above steps. If that did not work either, then try running the following command:
sudo find / -name ‘apt-get’
Method 12: Reinstalling OS
If none of these methods worked for you then you should try reinstalling your operating system. Doing so will help you get through the error easily. As something might have gone wrong during the installation procedure for the first time due to which you are not able to fully access what should normally be available to you. Before a clean reinstallation, you need to make a complete backup of your data and then proceed with the reinstallation. For reinstalling Ubuntu, you can try copying everything to your HDD from the USB drive, you can also try performing a system repair which might work out or you can install the APT package as mentioned in the steps above.
Follow the aforementioned methods in order to get through the error successfully but in case you have more queries in this regard feel free to Contact Us.