21

Is there a command for finding out the distribution of the OS I'm logged on to through SSH? uname can be used to print a whole lot of info, but apparently not the distribution (e.g. RedHat, Ubuntu etc.) nor the version of that distribution.

6 Answers 6

17

I am afraid, there is no standarized way to check it. Every distribution seems to have its own way of announcing its version. You may try: cat /etc/*release, it may work on a few systems. Also, /etc/issue may contain distribution information.

3
  • Thank you, both cat /etc/*release and /etc/issue give me the precise info I need.
    – vahidg
    Mar 4, 2010 at 13:03
  • On a base install of Debian (Lenny), /etc/*release doesn’t exist, but /etc/issue does (and has the right info).
    – David
    Mar 4, 2010 at 21:43
  • This is one of the only solutions that has worked for me consistently. Sep 7, 2012 at 18:14
8

lsb_release -a should work on most distributions.

5
  • Doesn’t seem to work on a base install of Debian (Lenny).
    – David
    Mar 4, 2010 at 21:42
  • Looks like lsb_release -i -s works across most of the systems I have just to get the vendor ID. Unfortunately lsb_release is not part of the base install on my smaller / embedded systems, so it has to be tested for first.
    – Caleb
    Jul 21, 2010 at 20:29
  • @Dave It's in the lsb-release package, which, indeed, is not default. It's absence is a strong Debian indicator, though. :-) Nov 26, 2010 at 11:41
  • Neither on OpenSuse.
    – ychaouche
    Aug 26, 2012 at 15:14
  • lsb_release doesn't exist on some new RHEL6 derivatives, such as Scientific Linux 6.1 or Fedora Linux 16. Sep 7, 2012 at 18:02
3

lsb_release and more /etc/redhat-release for redhat and fedora i dont have idea about ubuntu and all other distro

1
  • 1
    lsb_release -a works on Ubuntu too.
    – user8602
    Mar 4, 2010 at 20:57
-1

Generally /etc/motd gives the distribution name too...

-2

uname -o

The uname binary is found on almost every linux system and the -o flag does it's best to give you the operating system back. lsb_release works too but isn't quite as ubiquitous.

4
  • This fails on Ubuntu (lucid), however ubuntu has lsb_release, so first testing with uname -o, then if that comes back as just GNU/Linux, run lsb_release -i -s seems to work across all my systems.
    – Caleb
    Jul 21, 2010 at 20:31
  • This gives me "GNU/Linux" on RedHat, Debian and Ubuntu. On what does it work? Nov 26, 2010 at 11:43
  • GNU/Linux isn't very helpful. Most distros are GNU/linux ones.
    – ychaouche
    Aug 26, 2012 at 15:15
  • @ychaouche: See comment above. First test with uname and if all you get is generic, test for lsb_release and use that.
    – Caleb
    Aug 26, 2012 at 15:51
-3

If you use the -a flag on uname, it should work most of the time. For example, on my current Ubuntu machine uname -a prints:

Linux clark-laptop 2.6.35-25-generic #43-Ubuntu SMP Thu Jan 6 22:25:21 UTC 2011 x86_64 GNU/Linux

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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