Find if AWS instance is running Amazon Linux 1 or 2?

LP13 picture LP13 · Dec 17, 2018 · Viewed 22.2k times · Source

In AWS I need to add amazon linux instance to domain based on this article. However how do i know which Amazon Linux version the instance is using. I do not have access to AWS console. But i do have access to actual instance. What linux command i should be using.

I use uname -srm command which returns Linux 4.4.0-1057-aws x86_64

Not sure if this is Amazon Linux 1 or Amazon Linux 2

Answer

Hardeep Singh picture Hardeep Singh · Jun 13, 2019

You can use /etc/os-release file to get the info about Amazon Linux Version, the machine is running.

  1. In case of Amazon 1

    [ec2-user@ip-x-x-x- ~]$ cat /etc/os-release
    NAME="Amazon Linux AMI"
    VERSION="2018.03"
    ID="amzn"
    ID_LIKE="rhel fedora"
    VERSION_ID="2018.03"
    PRETTY_NAME="Amazon Linux AMI 2018.03"
    ANSI_COLOR="0;33"
    CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
    HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
    
  2. In case of Amazon 2

    [ec2-user@x-x-x-x ~]$ cat /etc/system-release
    Amazon Linux release 2.0 (2017.12) LTS Release Candidate
    [ec2-user@fresh-amazon-host ~]$ cat /etc/os-release
    NAME="Amazon Linux"
    VERSION="2.0 (2017.12)"
    ID="amzn"
    ID_LIKE="centos rhel fedora"
    VERSION_ID="2.0"
    PRETTY_NAME="Amazon Linux 2.0 (2017.12) LTS Release Candidate"
    ANSI_COLOR="0;33"
    CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2.0"
    HOME_URL="https://amazonlinux.com/"
    

As you can clearly see the two different versions, mentioned as Amazon Linux and Amazon Linux 2.0