Sometimes I need to access some servers running Linux (or maybe another Unix-like SO), but I don\'t know how to verify which distribution is in use on the server (there are
... is a quite professional BASH script that should have all the info you might desire.
(Disclaimer: I am not affiliated with it)
neofetch --stdout | grep '^OS: ' | sed -e 's/OS:[[:space:]]\+//'
might give:
Debian GNU/Linux 11 (bullseye) x86_64
but there is much more info.
Options:
system packaage neofetch
If that is not available, either see the official installation instructions
or for a hacky one-time use - if you have faith and an internet connection - you could use:
wget 'https://raw.githubusercontent.com/dylanaraps/neofetch/master/neofetch' \
&& bash neofetch --stdout \
&& rm neofetch
The proc file system: A directory in Linux with all the hardware level information. So just type
cd /proc/
There you will find a gold mine of information stored in a text file for all the arbitrary information about the system.
In my .cshrc
I have
setenv DISTRO `sed -e 's/.*(//' -e 's/)).*//' /proc/version`
For ksh / Bash users, I presume it translates to
export DISTRO=`sed -e 's/.*(//' -e 's/)).*//' /proc/version`
and of course this may not work for your favorite distribution. (I have had issues with Oracle's Unbreakable Linux giving something similar to Redhat, but it was good enough for my purposes.)
Update August 2016 I have not used Linux in this way for a while (2008 is a long time ago). It seems that this does not work anymore for the systems I now have.
Try uname -a
This is, annoyingly, a harder problem than it appears.
For Linux systems, use lsb_release.
$ lsb_release --all
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 8.04.1
Release: 8.04
Codename: hardy
$ lsb_release -i
Distributor ID: Ubuntu
This has the limitation that lsb_release works only for Linux releases.
For all Unix systems, you can also parse up uname.
$ uname -a
Linux blue-laptop 2.6.24-21-generic #1 SMP Tue Oct 21 23:43:45 UTC 2008 i686 GNU/Linux
You can find some information about the systems and distributions at the uname Wikipedia page.
cat /etc/*release
Most distributions put a release file in /etc/
(like /etc/redhat-release
, /etc/gentoo-release
, etc.) which usually has the version number of your distribution in it.