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
uname -r
should print the kernel version currently running (at least, it does for Linux, don't know if it's the same for *BSD or others). That's not the same as the distro but the kernel version often includes the distro name if it's customised, like "2.6.27-gentoo-r1" or something.
Init often prints something at boot, but that's not much good when it's running.
Otherwise as far as I know there isn't anything universal.
lsb_release -i
may work for you.
More detail is available with lsb_release -a
Some discussion at http://etbe.coker.com.au/2007/08/30/identifying-the-distribution-of-a-linux-system/
There are different commands you can use to check which distribution is in use. Here I am mentioning only 5 of them.
lsb_relase -a
lsb_release
provides distribution-specific information. Whereas -a
display all information about the distribution. You can also use -d
which only shows the description.
uname -a
uname
also provides system information. Whereas -a
display all information. You can use man uname
for other options.
cat /etc/*release
You can also use cat
command to print out all specific release information from etc folder. This command actually reads the lsb-release and os-release files from the /etc folder.
cat /etc/issue
This command reads the issue file from the /etc folder.
cat /proc/version
This command reads the version file from the /proc folder. /proc folder contains information about system process.
You should ask yourself if you really need to know which distro is in use (perhaps because you want to build a package specific for this distribution). In many other cases it is a far better idea, to just test and see if the features you need are there or not. This might look like a lot more work because you have to test every feature one by one but this way, your software becomes far more flexible.
I found that the /etc/issue usually has something about the distribution in use.
But I don't know about its availability on all distributions.
You can use 'uname':
[anton@localhost ~]$ uname -a
Linux localhost 2.6.26-ARCH #1 SMP PREEMPT Tue Aug 26 21:15:43 UTC 2008 i686 AMD Athlon(tm) 64 Processor 3000+ AuthenticAMD GNU/Linux