114

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?

11 Answers 11

103

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

| improve this answer | |
  • 3
    In 2016 it does not seem like lsb_release works any longer with modern distros. I tested the command on Amazon Linux AMI release 2016.03 and CentOS Linux 7 and it was not found. It seems like ls cat /etc/os-release is the best solution currently with uname -a somewhat usable if a bit opaque (e.g. Amazon Linux AMI release 2016.03 vs. Linux ip-x-x-x-x 4.4.11-23.53.amzn1.x86_64 #1 SMP Wed Jun 1 22:22:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux) – runamok Sep 19 '16 at 19:00
  • Well Done (y) :) – Sam Jun 9 '17 at 12:10
43

Use the following commands to get more details:

  1. cat /etc/*release*
  2. uname -a
| improve this answer | |
  • 4
    i like this answer better than the accepted one – Randy L Sep 22 '17 at 17:08
  • Add cat /proc/version and it covers every release I've found over the years. I've never seen a case where /proc/version wasn't helpful, but I've seen cases where one or both of the above don't help (can't remember which but most likely embedded systems.) – Jeff Learman Feb 25 at 15:13
5

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.

| improve this answer | |
4

Type in the command line:

uname -a

That'll give you all the information you seek.

Try also:

man uname to restrict the information

| improve this answer | |
4

To combine some ideas here:

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

Should get you want you need on any distribution.

| improve this answer | |
4

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.

| improve this answer | |
  • 1
    This worked for me – user919426 Apr 1 '18 at 19:50
  • 1
    On Apline 3.10.4 this returned something unexpected: Linux version 4.19.76-linuxkit (root@d203b39a3d78) (gcc version 8.3.0 (Alpine 8.3.0)) #1 SMP Thu Oct 17 19:31:58 UTC 2019 – b01 Feb 24 at 12:24
  • @b01 Thanks for the input. At least it got the Alpine part correct. ;-) Where did 3.10.4 come from, uname -a? It's sad that there is no single correct answer! – Jeff Learman Feb 25 at 15:08
  • I learned this while writing a tool that did a survey of connected systems which were embedded Linux running on various brands and models of storage servers. It was the only command I found that returned something useful in every case, and since then I've never seen it not be useful, even on BusyBox-based distros. – Jeff Learman Feb 25 at 15:20
  • @JeffLearman I was using a Go Lang Alpine Docker image of 1.13-alpine-3.10 and wanted to know the bug release number. I ended up trying quite a few of these answers to see which worked and not. – b01 Feb 26 at 18:50
3

For the Alpine distribution:

cat /etc/alpine-release
3.5.2
| improve this answer | |
3

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                                                                                                                                 
| improve this answer | |
  • 2
    This will work on Linux distros that use systemd. For older versions of those distros that don't use systemd, this won't work (e.g. RHEL 6), and for distros that don't use systemd at all this won't work. The second most voted answer will cat this file anyway, so there's no reason not to prefer that more general command. – Wildcard Aug 19 '19 at 23:48
  • @Wildcard Humm, I hadn't known it until you said that. Thanks. I'll keep in mind. – snr Aug 20 '19 at 9:44
2

Centos 5 using file in /etc/redhat-release

| improve this answer | |
1

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
| improve this answer | |
  • 1
    You might want to link to that tool or explain how you installed it, it's not on by default. – slm Aug 14 '18 at 16:12
0

For CentOs

$ cat /etc/centos-release
SHMZ release 6.6 (Final)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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