Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
uname -a should give you the information about the Kernel, build time, and some other info, including vendor... (courtesy of Tiernan0) –  soandos May 31 '11 at 20:00
add comment

4 Answers 4

up vote 6 down vote accepted

For distro info:

cat /etc/issue

For Kernel/architecture (as mentioned previously):

uname -a
share|improve this answer
    
cat /etc/issue worked. –  David Jun 2 '11 at 15:15
add comment

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)

But 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.

share|improve this answer
    
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? –  David May 31 '11 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. –  dannysauer May 31 '11 at 22:17
    
apt-get is not on the system. I don't see anything identifiable with rpm -qa|less. 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. –  David Jun 2 '11 at 15:15
add comment

uname -a should give you the information about the Kernel, build time, and some other info, including vendor...

share|improve this answer
add comment

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:

cat /usr/share/doc/system-release/ReleaseNotes.txt
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.