Linux – How to tell whether the system is Unix or Linux
linux
How can I tell whether my system is Unix or Linux?
I am using a Macbook Pro of 2010 vintage.
Best Answer
POSIX defines uname ("Unix name") to provide information about the operating system and hardware platform; running uname gives the name of the implementation of the operating system (or according to the coreutils documentation, the kernel). You can do this interactively in a terminal, or use the output in a script.
On Linux systems, uname will print Linux.
On Mac OS X systems, uname will print Darwin. (Strictly speaking, any operating system with a Darwin kernel will produce this, but you're very unlikely to encounter anything other than Mac OS X in this case.)
This will allow you to determine what any Mac is running. As Rob points out, if you're running Mac OS X (Darwin as indicated by uname), then you're running a certified version of Unix; if you're running Linux then you're not.
On a Mac there are many other possibilities; your script could end up running on Solaris (uname will print SunOS then), on FreeBSD (FreeBSD), on Windows with Cygwin (CYGWIN), MSYS or MSYS2 (MSYS), a MinGW or MinGW-w64 shell (MINGW64, MINGW32), Interix (Interix), and probably others I'm not aware of.
uname -a will print all the available information as determined by uname, but it's harder to parse.
If I need to know what it is say Linux/Unix , 32/64 bit
uname -a
This would give me almost all information that I need,
If I further need to know what release it is say (Centos 5.4, or 5.5 or 5.6)
on a Linux box I would further check the file /etc/issue to see its release info ( or for Debian / Ubuntu /etc/lsb-release )
Alternative way is to use the lsb_release utility:
lsb_release -a
Or do a rpm -qa | grep centos-release or redhat-release for RHEL derived systems
“Hardware Thread” in the dmidecode output corresponds to a specific flag in the processor characteristics value provided by SMBIOS (see section 7.5.9), and that is supposed to reliably indicate support for hardware threads, not all forms of single-package multi-processing. Thus on platforms with an SMBIOS,
Best Answer
POSIX defines
uname
("Unix name") to provide information about the operating system and hardware platform; runninguname
gives the name of the implementation of the operating system (or according to thecoreutils
documentation, the kernel). You can do this interactively in a terminal, or use the output in a script.On Linux systems,
uname
will printLinux
.On Mac OS X systems,
uname
will printDarwin
. (Strictly speaking, any operating system with a Darwin kernel will produce this, but you're very unlikely to encounter anything other than Mac OS X in this case.)This will allow you to determine what any Mac is running. As Rob points out, if you're running Mac OS X (
Darwin
as indicated byuname
), then you're running a certified version of Unix; if you're running Linux then you're not.On a Mac there are many other possibilities; your script could end up running on Solaris (
uname
will printSunOS
then), on FreeBSD (FreeBSD
), on Windows with Cygwin (CYGWIN
), MSYS or MSYS2 (MSYS
), a MinGW or MinGW-w64 shell (MINGW64
,MINGW32
), Interix (Interix
), and probably others I'm not aware of.uname -a
will print all the available information as determined byuname
, but it's harder to parse.