I just setup an EC2 instance running Linux. Is there a way to get the version/distribution of Linux that is running on the instance via the terminal?
uname -a should give you the information about the Kernel, build time, and some other info, including vendor... (courtesy of Tiernan0)– soandosMay 31, 2011 at 20:00
For distro info:
For Kernel/architecture (as mentioned previously):
cat /etc/issue worked. Jun 2, 2011 at 15:15
3Well, unless the sysadmin puts anything else in
/etc/issue, as that is a locally managed file which is displayed prior to login and could literally be anything (or nothing). :) For example, my systems currently say "systems require authorization, unauthorized access is illegal" in there. Anyone who cares about security at all probably doesn't put all of the OS identifying information in /etc/issue. Jul 14, 2017 at 22:06
@dannysauer where else would you put it. All information about anything is stored on the storage device. Sometimes I see this information embed in a binary executable that can print the information out, but that is little different in security measure than a plain text file, considering both any text file and any executable binary share the same filesystem based protections May 8, 2019 at 20:45
@ThorSummoner - the contents of /etc/issue are displayed before the login prompt. That's the security issue. May 11, 2019 at 22:42
The portable command for Linux Standard Base-compatible distributions (which is pretty much everything popular) is
lsb_release. The distribution can be obtained by "-i" and the version comes from "-r". The "-s" option suppresses the name column and just shows the value, and -a shows everything
lsb_release knows about the system. So, for example on a RHEL 5.5 system:
$ lsb_release -s -i RedHatEnterpriseServer $ lsb_release -s -r 5.5 $ lsb_release -a LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch Distributor ID: RedHatEnterpriseServer Description: Red Hat Enterprise Linux Server release 5.5 (Tikanga) Release: 5.5 Codename: Tikanga
If you're on Red Hat, SuSE, Ubuntu, Debian, or anything else derived from those (Fedora, CentOS, whatever), this command will work. Otherwise, you'll have to figure out some distro-specific info. RedHat, for example again, installs a package named
redhat-release and creates a file in /etc:
$ rpm -q redhat-release redhat-release-5Server-184.108.40.206 $ cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Here's what it looks like on a freshly-provisioned (Feb 2, 2017) Amazon Linux 2 system - after I reset the hostname:
[ec2-user@fresh-amazon-host ~]$ 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/"
IMHO, you really should use
lsb_release if it's available. If you're just doing it visually,
lsb_release -a is easy to remember and reasonably easy to read. But if that's not an option, /etc/os-release is populated as above on quite a few recent Linux OS versions.
I your first approach and get the following error
-bash: lsb_release: command not found. I also tried your second approach and can't find anything mentioning redhat in
/etc. Any other suggestions? May 31, 2011 at 21:42
Start by checking to see if rpm and apt-get are on the system; run "which rpm" and "which apt-get". If you have rpm, do an "rpm -qa | less" and see if there's anything there that sounds like a distribution. If you have apt-get, try "dpkg -l | less" and do the same thing. And try "ls -d /etc/*rel*" to see if there's any release file or anything in /etc. Oh, you might also do a "find / -name lsb_release" just in case lsb_release isn't in your path. May 31, 2011 at 22:17
apt-getis not on the system. I don't see anything identifiable with
ls -d /etc/*rel*worked. I then
nano /etc/system-release. In the file it tells me that the OS is
Amazon Linux AMI release 2011.02.1.1. Thanks. Jun 2, 2011 at 15:15
lsb_releaseisn't available on amazon linux, which generally leads to this question being asked...
lsb_releaserequires a large dep chain that comes with
redhat-lsb-coreand aws chooses to leave that off - forums.aws.amazon.com/message.jspa?messageID=519816– keenJan 18, 2018 at 23:28
2I made the rest of the answer more clear (which some people apparently weren't reading), and included the actual output from current Amazon Linux 2. Feb 8, 2018 at 4:24
This worked for me:
# cat /etc/os-release NAME="Amazon Linux AMI" VERSION="2015.03" ID="amzn" ID_LIKE="rhel fedora" VERSION_ID="2015.03" PRETTY_NAME="Amazon Linux AMI 2015.03" ANSI_COLOR="0;33" CPE_NAME="cpe:/o:amazon:linux:2015.03:ga" HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Just a heads up. I am running Amazon Linux AMI 2011.09 and this did not work but another comments
cat /usr/share/doc/system-release/ReleaseNotes.txtdid. This probably works on newer editions. Apr 3, 2015 at 20:34
uname -a should give you the information about the Kernel, build time, and some other info, including vendor...
As you can see when log into an AMI EC2 Amazon Linux AMI:
"See /usr/share/doc/system-release/ for latest release notes."
So... just type:
You can simply go on the
/etc/ folder and check it there. There is a file, named
system-release you can just
cat it and find out your system info.
~ cat /etc/system-release ~ Amazon Linux release 2 (Karoo)