What is the shell command to determine the version of Unix or Linux that is currently running?
What is the shell command to determine the number of CPU's?
Usually some variant of uname, often "uname -a", but all sorts of other
possibilies: -v, -X .. who knows? Depends on the flavor and in some
cases even the version of that flavor.
Sometimes /etc/issue has what you want.. and on some systems a "cat *-release" or "cat *-version" may give results. Also, some systems have /etc/issue and /etce/issue.net, with the latter being used for network logins.
To stir the confusion even more, some systems had /etc/.issue that they overwrote at boot, which allowed you to modify the /etc/issue and have it stick.
Oh, and one more thing:
Even when the man page tells you that uname -v gives you the version, it
can be an entirely different interpretation of version than what you
For example, on this 2.4 kernel Red Hat box, uname -r says 2.4.9-21.
That's good. But uname -v gives "#1" and todays date (yes, I did build
a new kernel today)
This 2.6 Linux shows me that PAE is enabled with "-r": "2.6.18-238.5.1.el5PAE"
On the SCO system I'm trying to recover for a client to my left, uname
-r says 3.2 and uname -v says "2", but uname -X says "Release=3.2v5.0.4"
(and "5.0.4" is what's important there)
On the BSD box to my right, uname -r says 4.1.1-STABLE and -v says that
Can't trust it unless you already know how it works :-)
Linux users can also "cat /proc/version", which is likely to give you something like this:
Linux version 2.6.18-238.5.1.el5PAE
(email@example.com) (gcc version 4.1.2
20080704 (Red Hat 4.1.2-50)) #1 SMP Mon Feb 21 06:01:16
Unixware had some oddities when SCO was calling it "Open Unix 8":
Then (I don't know about now) uname returned "OpenUNIX". You could get it to return "UnixWare" by doing
For Linux, it's all in /proc/cpuinfo. If you only care about the number, "grep processor /proc/cpuinfo" will give you that.
Unixware and SunOS have "psrinfo", which will tell you about processors.
Unixware "idtype" will tell you the kind of kernel it is running (for example, whether or not SMP).
Speaking of cpu stuff, this How do I Find Out Linux CPU Utilization? is useful.
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
More Articles by Tony Lawrence
Find me on Google+
© 2013-08-09 Tony Lawrence