linux commands

Amazon Linux AMI : apt-get command not found

Amazon Linux AMI is a Linux image supported and maintained by Amazon Web Services for use on Amazon EC2 instance. When I was trying to install package using apt-get command I got error apt-get command not found. Let’s see how to deal with apt package installation issues.

Amazon Linux AMI : apt-get command not found

When I was trying to install packages using apt-get I got the error below.

sudo: apt-get: command not found

Solution:

Amazon Linux is CentOS based. And CentOS is basically community version of RedHat. To install individual packages you need to enter the command in the following form using yum.

yum install <package_name>

Therefore, if you want to install packages in Amazon Linux AMI you need to install using yum and not apt-get.

For example, to install apache server on your AWS EC2 instance, you need to enter command in the following form.

yum install httpd24

How to find OS platform or version of Linux

To find OS platform or version of EC2 Linux instance , you can use one of the following three methods from Amazon EC2 console.

  1. View the platform details or AMI IS information.
  2. View the instance’s console logs or screenshot.
  3. View platform information for AWS Systems Manager Managed instances.

For more details check How can I find the OS platform or version of my EC2 Linux instance ?

Note: Amazon Linux 2

The Amazon Linux AMI had ended the standard support as of December 31, 2020. And customers are encouraged to upgrade their applications to use Amazon Linux 2 for which there is a long term support through 2023.

And Amazon Linux 2 has moved to different Linux platform from CentOS. But still it uses yum.

For example, to find the OS platform or version from AWS CLI on managed instances try the following commands.

# sudo yum install -y jq*

# aws ssm describe-instance-information --query 'InstanceInformationList[*].[InstanceId,PlatformType,PlatformName]' --output table  --region us-east-1
------------------------------------------------------
|             DescribeInstanceInformation            |
+----------------------+--------+--------------------+
|  i-0e446328e4070b25c |  Linux |  SLES              |
|  i-09ab5fd0cf37a45da |  Linux |  Amazon Linux AMI  |
|  i-0dd6cd6c3210f605e |  Linux |  SLES              |
|  i-05dd60329fb29cd74 |  Linux |  Ubuntu            |
+----------------------+--------+--------------------+

$ aws ssm describe-instance-information --region us-east-1
{
    "InstanceInformationList": [
        {
            "IsLatestVersion": false, 
            "ComputerName": "ip-172-31-39-244.ec2.internal", 
            "PingStatus": "Online", 
            "InstanceId": "i-0b89uiydekijihuh", 
            "IPAddress": "172.31.39.244", 
            "ResourceType": "EC2Instance", 
            "AgentVersion": "2.3.978.0", 
            "PlatformVersion": "15.1", 
            "PlatformName": "SLES", 
            "PlatformType": "Linux", 
            "LastPingDateTime": 1593669078.246
        }
}

That’s it. By using yum instead of apt-get the error Amazon Linux AMI : apt-get command not found should have gone now.

Hope it helped 🙂

References

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments