How to fix "apt get command not found"?

Ujjwal Pratap singh 20 Reputation points
2023-07-28T02:14:02.5+00:00

while exercising, I have to install Nginx due to which I have to update my shell. I gave "apt-get update" command but it shows "apt get command not found". How to fix it?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,585 questions
{count} votes

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 26,021 Reputation points
    2023-07-28T03:24:54.05+00:00

    Hello Ujjwal Pratap singh

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    As you mentioned you need to install Nginx, I assume you are using a Linux distribution that supports the 'apt' package manager (such as Debian, Ubuntu, or their derivatives). If you are using a different distribution, the package manager and commands may differ, and you should use the appropriate package manager for your system.

    Here's how you can fix the "apt-get command not found" issue on a system that should have 'apt' installed:

    Step:1 - Confirm whether 'apt-get' is already installed on your system by running the command:

    which apt-get

    If it does not return anything, then Install 'apt' as mentioned below.

    Try installing the package that provides 'apt-get' using the package manager specific to your Linux distribution.

    sudo apt update

    sudo apt install apt

    If the command (Step:1) returns a path (e.g., /usr/bin/apt-get), it means 'apt-get' is installed, and the issue might be related to your system's PATH configuration.

    To ensure that the 'apt-get' binary is accessible from your shell, you can add its location to your PATH.

    Open your shell configuration file (such as ~/.bashrc, ~/.bash_profile, ~/.zshrc, or ~/.profile) with a text editor like 'nano' or 'vim'. For example:

    nano ~/.bashrc

    Add the following line to the file if it's not already there, save the file and exit the text editor.

    export PATH="/usr/bin:$PATH"

    Apply the changes to your current shell session:

    source ~/.bashrc # or source ~/.bash_profile, source ~/.zshrc, etc., depending on your configuration file

    Verify 'apt-get' installation

    apt-get update

    It should work without any errors.

    Hope this helps.