Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 13 years ago.
Improve this questionMoved to https://superuser.com/questions/80251/how-to-know-which-linux-distribution-im-using
How to know which Linux Distribution I'm using?
uname -a gives Linux xxxxxx.net 2.6.9-42.0.3.EL.wh1smp #1 SMP Fri Aug 14 15:48:17 MDT 2009 i686 i686 i386 GNU/Linux How can I know this is Ubuntu/Debian/Fedora or Redhat?
I uses /etc/init.d/serviced restart for restarting serevices, seems it is not Redhat family
Update:
[~]$ cat /etc/issue
cat: /etc/issue: No such file or directory
[~]$ cat /etc/issue.net
cat: /etc/issue.net: No such file or directory
[~]$ lsb_release -a
-sh: lsb_release: command not found
[~]$ cat /etc/*-release
cat: /etc/*-release: No such file or directory
[~]$ cat /etc/*-version
cat: /etc/*-version: No such file or directory
[~]$ cat /etc/*release
cat: /etc/*release: No such file or directory
[~]$ cat /etc/*_release
cat: /etc/*_release: No such file or directory
[~]$ cat /etc/*version
cat: /etc/*version: No such file or directory
[~]$
Try this:
cat /etc/*-release
You could also try /etc/*-version
If you have lsb_release
command,
lsb_release -a
will tell you (or just use lsb_release -i
).
lsb_release
is in Linux Standard Base Core Specification.
Edit: Looks like you're on a Red Hat system. A google search on your uname
output suggests so. This is not programmatic, of course!
/etc/issue or /etc/issue.net give a good clue. Newer distros provide /etc/lsb-release which make it easier to determine exact strings progmatically, i.e. distro name / major & minor release / web site, etc.
In the absence of /etc/lsb-release, its much more difficult, hence the creation of lsb-release.
As Alok said, it looks like you are on a rather ancient (or extremely sparse) system. I don't think this is a case that you can (reliably) progmatically determine with a few lines of code.
If all else fails, check to see what kind of package manager is in use (apt / rpm / others), check to see if /etc/init.d is a symlink (rpm / RH distros) or a directory (debian based distros) .. and you have a pretty good clue as to what you can expect to be present in the root file system as far as structure.
You can't please everyone :)
Seems like here's some info:
> cat /etc/issue
Welcome to SUSE LINUX Enterprise Server 9 (i586) - Kernel \r (\l).
> uname -a
Linux boxname 2.6.5-7.244-smp #1 SMP Mon Dec 12 18:32:25 UTC 2005 i686 athlon i386 GNU/Linux
> cat /etc/*-release
SUSE LINUX Enterprise Server 9 (i586)
VERSION = 9
PATCHLEVEL = 3
A list the release filenames for the most common distros: Release files
And a function that might help you: Shell script
EL stands for Enterprise Linux in this case, so I think RedHat or a clone (like CentOS). I don't know a good way to programatically find out what distro you're on; there's a few different clues for each one.
cat /etc/redhat_release
cat /etc/debian_version
is a good start. (Note the Ubuntu doesn't modify /etc/debian_version
when they pull changes from Debian, so my Ubuntu Karmic system has squeeze/sid in debian_version.)
Edit: forgot about lsb. Good call, Tim Post and Alok. The whole point of LSB is to give distro-independent ways to do things.
精彩评论