Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

I want to write a script that can run on all the different Linux Distributions (Mandrake, Red Hat, Debian, SuSE, Slackware, Lycoris....) and will print for me the name of the Linux Distribution and its version. The output of the script will be something like: "This machine runs Red Hat Linux Version 7.2" or "This machine runs Mandrake Linux Version 8.2"...

I tried using the uname command but that gives only the kernel version number and does not give the name of the distribution. I tried a number of ways to get the information (for example in case of Red Hat there is a file /etc/redhat-release that contains this information) but could not find a general way that will work on all the distributions.

Is there a way to do this ? Any suggestions will be of great help.

Thanks.

Click here to see the post LQ members have rated as the most helpful post in this thread.

There isn't really any standard way common to all distributions. If you want that information you will have to get it from the /etc/<distro>-release file. Not sure if all distributions do that though.
I know redhat, mandrake and suse do though. Just test for the presence of the different files. I've got an LFS system and the only way to recognize that is because I did a touch /etc/lfs-<version> like the book suggests. But I guess there would be a million more ways to identify a certain system.

I hate to dig up a really really old thread, but... I was wondering how exactly uname goes about finding the name of a distro. In my case, I would like to make my own "distro" customized from the live cd of Ubuntu. I would like uname -s and uname -o to print the name of my distro instead of "Ubuntu"

Also, on a slightly unrelated note, I was wondering if this change would affect the way grub recognized the name of the distro. what I mean by that is... When I install GRUB on a computer that already has a linux distro on it, it normally will correctly identify the name and version of the distro and add it to it's menu.lst. I am wondering how GRUB goes about doing this.

but I don't recommend changing them cause that would make some apps stop working
like ubuntu-tweak for example which dose different tasks to each version and if your version is not recognized some functions will not work