20

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.

16

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.

  • Thank you, both cat /etc/*release and /etc/issue give me the precise info I need. – vahidg Mar 4 '10 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 '10 at 21:43
  • This is one of the only solutions that has worked for me consistently. – Stefan Lasiewski Sep 7 '12 at 18:14
8

lsb_release -a should work on most distributions.

  • Doesn’t seem to work on a base install of Debian (Lenny). – David Mar 4 '10 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 '10 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. :-) – Daniel C. Sobral Nov 26 '10 at 11:41
  • Neither on OpenSuse. – ychaouche Aug 26 '12 at 15:14
  • lsb_release doesn't exist on some new RHEL6 derivatives, such as Scientific Linux 6.1 or Fedora Linux 16. – Stefan Lasiewski Sep 7 '12 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
    lsb_release -a works on Ubuntu too. – user8602 Mar 4 '10 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.

  • 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 '10 at 20:31
  • This gives me "GNU/Linux" on RedHat, Debian and Ubuntu. On what does it work? – Daniel C. Sobral Nov 26 '10 at 11:43
  • GNU/Linux isn't very helpful. Most distros are GNU/linux ones. – ychaouche Aug 26 '12 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 '12 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.