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.

link|improve this question
feedback

6 Answers

up vote 12 down vote accepted

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.

link|improve this answer
Thank you, both cat /etc/*release and /etc/issue give me the precise info I need. – Wesho 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). – Dave Mar 4 '10 at 21:43
feedback

lsb_release -a should work on most distributions.

link|improve this answer
Doesn’t seem to work on a base install of Debian (Lenny). – Dave 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
feedback

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

link|improve this answer
1  
lsb_release -a works on Ubuntu too. – bytesum Mar 4 '10 at 20:57
feedback

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

link|improve this answer
feedback

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.

link|improve this answer
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
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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