122

Amazon Web Services (AWS) offers an officially supported Amazon Machine Image (AMI), but it doesn't indicate which Linux distribution it's based upon.

Is the official Amazon Linux AMI based on another Linux distribution, and if so, which one?

2
  • 7
    Amazon Linux is relatively poorly documented. Because it's somewhat based on Centos sometimes that information works, but there's a lot less information than for say Ubuntu. My prod servers run on AL but I'd use Ubuntu LTS next time.
    – Tim
    Aug 22, 2016 at 20:02
  • 2
    It's Centos Red Hat Enterprise Linux. Just type uname -m && cat /etc/*release May 23, 2021 at 3:45

7 Answers 7

106

Instead of guessing which version of RHEL a particular distro is based off, just run:

rpm -E %{rhel}

For Amazon Linux 2, this will give you 7.

2
  • 5
    this should be the accepted answer. anything else is going to be out of date and this is how you can actually determine the RPM repos you need to use Mar 31, 2020 at 15:59
  • 4
    What does 7 mean? Does a number correspond to a Linux distribution?
    – Diego
    Oct 29, 2022 at 19:08
34

There's a discussion thread available over on the AWS forums that indicates the officially supported Amazon Linux AMI is not based upon any Linux distribution. Rather, the Amazon Linux AMI is independently maintained image by Amazon.

5
  • 16
    IIRC it started off as a RHEL/CentOS modification. It has changed enough that you can probably call it a separate distro now, but it retains a lot of their legacy - yum etc. google.com/search?q=amazon+linux+centos You'll note that your linked AWS forum thread states The Amazon Linux AMI is based on RHEL 5.x and parts of RHEL6. but that was back in 2010. More recently they state one of the goals of the most current Amazon Linux AMI (2013.09) is to be as compatible as possible with RHEL 6.
    – ceejayoz
    Aug 22, 2016 at 19:59
  • 22
    @ceejayoz In 2016, that goal is long gone. Amazon Linux hasn't been compatible with RHEL anything in quite a while. Indeed, here we have at least hundreds of questions from people trying to use packages for RHEL/CentOS on Amazon Linux and them not working, for precisely this reason. Aug 22, 2016 at 20:03
  • @MichaelHampton 2013 marks about the end of my Amazon Linux experience, so I defer to you there. :-)
    – ceejayoz
    Aug 22, 2016 at 20:24
  • 1
    The discussion referenced is many years old, and even there the most recent comment (2013) states: " one of the goals of the most current Amazon Linux AMI (2013.09) is to be as compatible as possible with RHEL 6. If there are places in which you find that we are not, please let us know so that we can investigate further." Jan 1, 2017 at 10:41
  • best Guess is using uname -a returns kernel "amzn1" - centos6, "amzn2" - centos7 ; Notice 4.14.97-74.72.amzn1.x86_64 #1 SMP Tue Feb 5 20:59:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    – wwright
    Apr 29, 2019 at 15:14
28

Seems like it's based on RHEL:

$ cat /etc/os-release
NAME="Amazon Linux AMI"
VERSION="2017.09"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2017.09"
PRETTY_NAME="Amazon Linux AMI 2017.09"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2017.09:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

freedesktop says of "ID_LIKE":

It should list identifiers of operating systems that are closely related to the local operating system in regards to packaging and programming interfaces, for example listing one or more OS identifiers the local OS is a derivative from.

listing one or more OS identifiers the local OS is a derivative from

If you were to look at RHEL/CentOS7 the same file would read:

$ cat /etc/os-release
...
ID_LIKE="fedora"
...

And yet, Amazon Linux still features yum and no dnf in sight; weird. Speculation leads me to support the theory that Amazon has a supported upstream agreement with RH.

That it's based on RHEL 5/6 seems extremely unlikely.

  1. Nobody should be using RHEL5x, because
  2. There are too many drivers and security updates introduced over the last 10 years.

That would be both lazy and stupid; 2 things I wouldn't normally ascribe to Amazon's engineers. One way to determine that would be to isolate something that is only present in the latest version of RHEL7, a driver, kernel security patch, etc. and run the same test on Amazon Linux; it's either present or it's not.

While far less irresponsible, there's no valid reason to even use RHEL6x either.

2
  • 2
    A check on my image suggests it uses upstart as init by default, so that would indicate RHEL6 as the basis (as RHEL7 uses systemd).
    – Jules
    May 12, 2018 at 10:48
  • I didn't check for or notice upstart anywhere. You might be right. I skipped RHEL6 entirely while at another company that only supported suse.
    – todd_dsm
    May 15, 2018 at 1:23
20

A bit late, but you can run:

cat /proc/version

and will tell you:

Linux version 4.14.173-137.229.amzn2.x86_64 (mockbuild@ip-10-0-1-143) (gcc version 7.3.1 20180712 (Red Hat 7.3.1-6) (GCC)) #1 SMP Wed Apr 1 18:06:08 UTC 2020

RedHat 7 in this case.

4
  • Good one! Better late... Sep 9, 2020 at 8:08
  • Or just uname -a
    – Amit Naidu
    Oct 6, 2020 at 21:29
  • Great answer. The best of the lot. This command clearly states Red Hat 7.3.1-6. That is what I was exactly looking for. Thanks! Dec 17, 2020 at 7:26
  • 1
    Nope, that RedHat 7.x is just a part of the gcc-version string. amzn1 gives me: (Red Hat 7.2.1-2); centos-6.x gives me: (Red Hat 4.4.7-18)
    – bk-se
    Feb 4, 2021 at 5:03
8

Based on file structure where instead of /usr/local/bin/composer I have to use /usr/bin/composer it is CentOS 7

1
  • 13
    AMI is definitely CentOS 6.x, whereas Amazon Linux 2 is CentOS 7.x. Nov 22, 2018 at 8:23
2

Its absurd to state that Amazon Linux 2 is not based on any of the popular linux distributions but is an entity of its own. How is someone supposed to install other linux packages that are not certified for Amazon Linux ? So, I have Amazon Linux 2 installed. It seems to be based on RHEL 7. Output of cat /etc/os-release:

NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

Output of cat /proc/version:

Linux version 4.14.203-156.332.amzn2.x86_64 (mockbuild@ip-10-0-1-132) (gcc version 7.3.1 20180712 (Red Hat 7.3.1-10) (GCC)) #1 SMP Fri Oct 30 19:19:33 UTC 2020
2
  • 3
    This is why it's often better to use a different distro for general purpose computing. Ubuntu, Centos, etc.
    – Tim
    Dec 17, 2020 at 7:52
  • 4
    It was forked from CentOS 7 quite some time ago, but it is no longer compatible. Dec 17, 2020 at 8:03
1

The easiest place to get this answer is from the horses mouth. "AL2023 is RPM-based and includes components sourced from multiple versions of Fedora and other distributions, such as CentOS 9 Stream. The Amazon Linux kernel is sourced from the long-term support (LTS) releases directly from kernel.org, chosen independently from other distributions."

https://docs.aws.amazon.com/linux/al2023/ug/compare-with-al2.html#building-on-fedora

https://docs.aws.amazon.com/linux/al2023/ug/relationship-to-fedora.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .