How can I check if the Operating System is Sun Os or Unix or Solaris from by bashrc

StackOverflow https://stackoverflow.com/questions/9124357

  •  22-04-2021
  •  | 
  •  

Pergunta

I want to know, how can we check in the bashrc file, what operating system is it?

Foi útil?

Solução

Use uname -a in your .bashrc file.

Outras dicas

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

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"
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top