linux - How to get Amazon EC2 instance operating system info?

09
2013-08
  • David

    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?

  • Answers
  • CJ Travis

    For distro info:

    cat /etc/issue
    

    For Kernel/architecture (as mentioned previously):

    uname -a
    
  • dannysauer

    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 RedHat, 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.

  • studiohack

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


  • Related Question

    amazon ec2 - Minimal footprint ubuntu for ec2 micro instance?
  • Abjs

    I want to run a minimal footprint ubuntu on the new amazon ec2 micro instance.

    Is there a pre-built minimum ebs image available somewhere? I'm guessing the official ubuntu ec2 images are not minimal and are probably loaded with everything?


  • Related Answers
  • Beau Simensen

    I have been looking for information on this as well. The best I've found so far is a post from smoser saying that for the most part the standard small AMI work fine with the exception of a bug that will cause the instance to halt on reboot.

    The bug has apparently been fixed for 10.10 already, but the fix is not in 10.04 yet. The listed fix is to run the following after the instance is running the first time:

    arch=$(uname -m)
    [ "$arch" = "x86_64" ] && ephd=/dev/sdb || ephd=/dev/sda2
    sudo sed -i.dist "\,${ephd},s,^,#," /etc/fstab
    

    (the problem is that micro instances are EBS only and the default Ubuntu AMI's currently assume that the ephemeral devices will exist and they do not)