This article mainly introduces how to view the current shell in linux. For more information, see
1. view the shell types used in the current process in real time: recommended
Copy codeThe code is as follows:
Ps | grep $ | awk '{print $4 }'
(Note: $ indicates the shell process number)
2. the most common command for viewing shell, but it cannot reflect the current shell in real time
Copy codeThe code is as follows:
$ Echo $ SHELL
3. more concise, but not all shells support
Copy codeThe code is as follows:
$ Echo $0
4. search for shell matching in environment variables
Copy codeThe code is as follows:
Env | grep SHELL
5. search for shell matching in the password file
Copy codeThe code is as follows:
Cat/etc/passwd | grep muye
6. when using ps-ef
Copy codeThe code is as follows:
$ Ps-ef | grep $ | grep-v grep | grep-v ps
Note: grep-v indicates inverse, as shown below:
Copy codeThe code is as follows:
Muye @ bupt :~ $ Ps-ef | grep $
Muye 4750 4745 0 00:00:00 pts/1 bash
Muye 5331 4750 0 00:00:00 pts/1 ps-ef
Muye 5332 4750 0 00:00:00 pts/1 grep -- color = auto 4750
Remove the last two