How to get Amazon EC2 instance operating system info?
For distro info:
cat /etc/issue
For Kernel/architecture (as mentioned previously):
uname -a
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-5.5.0.2
$ 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.
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/"
uname -a
should give you the information about the Kernel, build time, and some other info, including vendor...