How can I tell what version of Linux I'm using?

Often times I will ssh into a new client’s box to make changes to their website configuration without knowing much about the server configuration. I have seen a few ways to get information about the system you’re using, but are there some standard commands to tell me what version of Unix/Linux I’m on and basic system information (like if it is a 64-bit system or not), and that sort of thing?

Basically, if you just logged into a box and didn’t know anything about it, what things would you check out and what commands would you use to do it?

Asked By: cwd

||

You should look into the uname command.

I have to deal with a large parc of heterogenous machines. uname -a is usually my first reflex when I log in.

Answered By: rahmu

Type in the command line:

uname -a

That’ll give you all the information you seek.

Try also:

man uname to restrict the information

Answered By: Jose Elera

If I need to know what it is say Linux/Unix , 32/64 bit

uname -a 

This would give me almost all information that I need,

If I further need to know what release it is say (Centos 5.4, or 5.5 or 5.6)
on a Linux box I would further check the file /etc/issue to see its release info ( or for Debian / Ubuntu /etc/lsb-release )

Alternative way is to use the lsb_release utility:

lsb_release -a

Or do a rpm -qa | grep centos-release or redhat-release for RHEL derived systems

Answered By: Gaumire

Centos 5 using file in /etc/redhat-release

Answered By: Kurdt94

Use the following commands to get more details:

  1. cat /etc/*release*
  2. uname -a
Answered By: Alapati

Use cat /proc/version

Result:

Linux version 3.14.27-100.fc19.x86_64 (mockbuild@bkernel02.phx2.fedoraproject.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC) ) #1 SMP Wed Dec 17 19:36:34 UTC 2014

I believe this works for most distros, and provides a more concise answer than cat /etc/*release* and more complete answer than uname -a. However, use of /proc for things other than processes is now eschewed, so maybe it’ll disappear someday.

Answered By: Jeff Learman

For CentOs

$ cat /etc/centos-release
SHMZ release 6.6 (Final)
Answered By: Joao Leme

For the Alpine distribution:

cat /etc/alpine-release
3.5.2
Answered By: mkobit

To combine some ideas here:

cat /etc/*_version /etc/*-release && uname -a

Should get you want you need on any distribution.

Answered By: Adam Grant

whatami by Remy Evard at Argonne National Lab. Install and run using these commands:

$ wget https://raw.githubusercontent.com/open-mpi/mtt/master/client/whatami/whatami && chmod a+x whatami
Resolving raw.githubusercontent.com... 151.101.116.133
Connecting to raw.githubusercontent.com|151.101.116.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24434 (24K) [text/plain]
Saving to: 'whatami'

whatami                                           100%[============================================================================================================>]  23.86K  --.-KB/s    in 0.02s   

2018-08-15 18:54:42 (1.49 MB/s) - 'whatami' saved [24434/24434]

$ ./whatami
darwin-macosx_10.11-x86_64
Answered By: emallove

There are a ton of answers but I’m looking for more generic. AFAI am concerned the following works on most of systems.

cat /etc/os-release

Example output:

sh-4.4$ cat /etc/os-release                                                                                                                                                                           
NAME=Fedora                                                                                                                                                                                           
VERSION="26 (Twenty Six)"                                                                                                                                                                             
ID=fedora                                                                                                                                                                                             
VERSION_ID=26                                                                                                                                                                                         
PRETTY_NAME="Fedora 26 (Twenty Six)"                                                                                                                                                                  
ANSI_COLOR="0;34"                                                                                                                                                                                     
CPE_NAME="cpe:/o:fedoraproject:fedora:26"                                                                                                                                                             
HOME_URL="https://fedoraproject.org/"                                                                                                                                                                 
BUG_REPORT_URL="https://bugzilla.redhat.com/"                                                                                                                                                         
REDHAT_BUGZILLA_PRODUCT="Fedora"                                                                                                                                                                      
REDHAT_BUGZILLA_PRODUCT_VERSION=26                                                                                                                                                                    
REDHAT_SUPPORT_PRODUCT="Fedora"                                                                                                                                                                       
REDHAT_SUPPORT_PRODUCT_VERSION=26                                                                                                                                                                     
PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy                                                                                                                                 

inxi is a System Information Tool for Linux. It displays handy information concerning system hardware (hard disk, sound cards, graphic card, network cards, CPU, RAM, and more), together with system information about drivers, Xorg, desktop environment, kernel, GCC version(s), processes, uptime, memory, and a wide array of other useful information.

If inxi is not installed in your system, you can install it by:

$ sudo apt install inxi       [On Debian/Ubuntu/Linux Mint]
$ sudo yum install inxi       [On CentOs/RHEL/Fedora]
$ sudo dnf install inxi       [On Fedora 22+]

In manpage you can fine that -S option can be used to get host name, kernel, desktop environment (if in X/Wayland), distro.

% inxi -S
System:    Host: blueray-i5 Kernel: 5.4.0-53-generic x86_64 bits: 64 Desktop: Cinnamon 4.6.7 Distro: Linux Mint 20 Ulyana

This can be used as a debugging, and/or forum technical support tool. So you might consider keeping it in your toolbelt.

Answered By: Ahmad Ismail

A problem I found with the practical uname-a is that, in microsoft’s wsl, it always returns something like (even inside docker containers!):

Linux d0b341b1f694 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 Linux

On the other hand, when using cat /etc/os-release (or cat /etc/*release*), also in wsl, it returns the correct system of the container (or of the linux distro).

Answered By: kaiserlautern