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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
Method 2
Use the following commands to get more details:
cat /etc/*release*uname -a
Method 3
Use cat /proc/version
Result:
Linux version 3.14.27-100.fc19.x86_64 (<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="117c7e727a7364787d7551737a74637f747d21233f617969233f7774757e637061637e7b7472653f7e6376">[email protected]</a>) (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.
Method 4
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
Method 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.
Method 6
For the Alpine distribution:
cat /etc/alpine-release 3.5.2
Method 7
To combine some ideas here:
cat /etc/*_version /etc/*-release && uname -a
Should get you want you need on any distribution.
Method 8
Type in the command line:
uname -a
That’ll give you all the information you seek.
Try also:
man uname to restrict the information
Method 9
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.
Method 10
Centos 5 using file in /etc/redhat-release
Method 11
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
Method 12
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).
Method 13
For CentOs
$ cat /etc/centos-release SHMZ release 6.6 (Final)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0