I want to know, how can we check in the bashrc file, what operating system is it?
Asked
Active
Viewed 3.7k times
3 Answers
18
Use uname -a
in your .bashrc
file.

Basile Starynkevitch
- 223,805
- 18
- 296
- 547
-
6Or just `uname -s` if you don't need the version number and other information. – mark4o Feb 03 '12 at 06:46
6
There is no portable way to know what Operating System is running.
Depending on the OS, uname -s
will tell you what kernel you are running but not necessarily what OS.
Moreover, it cannot be SunOS or Unix or Solaris. Solaris is all of them: both a Unix compliant OS and an OS based on the SunOS kernel.
One of these might give you a precise answer depending on the Unix or Linux implementation:
cat /etc/release # SVR4, Solaris
cat /etc/redhat-release
cat /etc/*elease
cat /etc/lsb-release
oslevel -r # AIX
system_profiler -detailLevel -2 # Mac OS/X

jlliagre
- 29,783
- 6
- 61
- 72
4
Try this:
$cat /etc/os-release
NAME="Ubuntu"
VERSION="12.04.4 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.4 LTS)"
VERSION_ID="12.04"
-
And what's that supposed to do? Basile's answer seems to cover this question just fine, so please explain what this code improves compared to Basile's. – Joeytje50 May 13 '14 at 00:16
-
LOL.. whatever.. it's not code btw.. just a more specific answer to a question. – May 15 '14 at 21:45
-
:) Thanks user.. +1 for the precise answer.. though.. I just wanted the OS name, which was answered earlier by Basile, and it fitted my needs. Also the answer by jlliagre gave me these information as well. – Kumar Alok May 20 '14 at 06:30