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
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.– vahidgMar 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).– DavidMar 4, 2010 at 21:43
-
This is one of the only solutions that has worked for me consistently. Sep 7, 2012 at 18:14
lsb_release -a
should work on most distributions.
-
-
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.– CalebJul 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 -
-
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
lsb_release and more /etc/redhat-release for redhat and fedora i dont have idea about ubuntu and all other distro
-
1lsb_release -a works on Ubuntu too.– user8602Mar 4, 2010 at 20:57
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, runlsb_release -i -s
seems to work across all my systems.– CalebJul 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
-
-
@ychaouche: See comment above. First test with uname and if all you get is generic, test for lsb_release and use that.– CalebAug 26, 2012 at 15:51
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