Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 16 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.

share|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). – 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

lsb_release -a should work on most distributions.

share|improve this answer
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

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

share|improve this answer
lsb_release -a works on Ubuntu too. – agporwfnz29 Mar 4 '10 at 20:57

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

share|improve this answer

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.

share|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
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

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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