295

This question already has an answer here:

What is the Linux command to check the server OS and its version?

I am connected to the server using shell.

marked as duplicate by jasonwryan, Anthon, manatwork, a CVn, rahmu Aug 29 '13 at 9:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

372

Kernel Version

If you want kernel version information, use uname(1). For example:

$ uname -a
Linux localhost 3.11.0-3-generic #8-Ubuntu SMP Fri Aug 23 16:49:15 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Distribution Information

If you want distribution information, it will vary depending on your distribution and whether your system supports the Linux Standard Base. Some ways to check, and some example output, are immediately below.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu Saucy Salamander (development branch)
Release:    13.10
Codename:   saucy

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.10
DISTRIB_CODENAME=saucy
DISTRIB_DESCRIPTION="Ubuntu Saucy Salamander (development branch)"

$ cat /etc/issue.net
Ubuntu Saucy Salamander (development branch)

$ cat /etc/debian_version 
wheezy/sid
  • CodeGnome, why not use uname -o – debal Aug 29 '13 at 6:16
  • 9
    @debal Because on Linux systems all it returns is GNU/Linux, which is not what the OP is likely asking for. – CodeGnome Aug 29 '13 at 6:17
  • 4
    Just checked it, and you are correct. lsb_release -a did the trick. Thanks. – debal Aug 29 '13 at 6:23
  • 1
    I tried cat /etc/issue and it gives me result as: \S Kernel \r on an \m, what does it mean? – ray Jul 5 '17 at 7:35
  • @Ray, get the same for CentOS 7, issue.net for Red Hat case is used to identify the format of print out message. \r for "Inset the release number", \m for "insert the architecture identifier of the machine". – zhihong Oct 25 '18 at 12:45
57

You can execute cat /etc/redhat-release to check the Red Hat Linux (RH) version if you use an RH-based OS.

Another solution that may work on any linux distributions is lsb_release -a.

And the uname -a command shows the kernel version and other things.

Also cat /etc/issue.net shows your OS version... This file shows in the telnet command when you want to connect to the server. For security reasons, it is better to delete the version and os name in this file.

  • 2
    "cat /etc/issue.net" works on Raspberry Pi. For example, "Raspbian GNU/Linux 7" – Peter Mortensen Oct 27 '15 at 13:27
  • Telnet? I thought it was ssh these days(?) – Peter Mortensen Oct 27 '15 at 13:30
44

If it is a debian based system, you could do

cat /etc/*_version

or for a Red Hat based system, you could try (this is working on Red Hat Enterprise Linux-7):

cat /etc/*-release
  • 1
    cat /etc/*-release - works for me. I have /etc/alpine-release and /etc/os-release. – Kirby Jul 13 '17 at 11:31
  • Also works for CentOS – TimSparrow Aug 23 '18 at 14:52

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