PS | grep $$ | awk ' {print $4} '
PS command without parameters displays the status of the process associated with the current terminal
$$ variable stores the PID of the current process
PS Fourth column is the command used by the process, if it is a shell, then display the shell name, such as Sh/ksh, etc.
awk ' {print $4} ' is only showing the value of column fourth
PS: Use echo $SHELL to view the system's default SHELL
View the shell that the current release can use
[Email protected] ~]$ Cat/etc/shells
/bin/sh
/bin/bash
/sbin/nologin
View the currently used shell
One, the most common command to view the shell, but cannot reflect the current shell in real time
[Email protected] ~]$ echo $SHELL
/bin/bash
Second, the following usage is not supported by all shells
[Email protected] ~]$ Echo
Bash
Third, the shell matching search in environment variables
[Email protected] ~]$ env | grep SHELL
Shell=/bin/bash
Four, the password file in the shell matching search
[Email protected] ~]$ CAT/ETC/PASSWD | grep, Jack.
Jack:x:500:500:mengfei:/home/jack:/bin/bash
V. Viewing the current process
[[Email protected] ~]$ PS
PID TTY Time CMD
3052 pts/0 00:00:00 Bash
3254 pts/0 00:00:00 PS
Six, first view the current shell PID, and then navigate to this shell process
[Email protected] ~]$ echo $$
3052
[Email protected] ~]$ Ps-ef | grep 3052
Jack 3052 3047 0 11:33 pts/0 00:00:00 bash
Jack 3420 3052 0 11:57 pts/0 00:00:00 ps-ef
Jack 3421 3052 0 11:57 pts/0 00:00:00 grep 3052
Attached: One command can be implemented:
[Email protected] ~]$ Ps-ef | grep ' echo $$ ' | Grep-v grep | Grep-v PS
Jack 3052 3047 0 11:33 pts/0 00:00:00 bash
Enter a non-existing command to see the shell prompt for the error
[Email protected] ~]$ Tom
Bash:tom:command not found
Original posts: http://rickie622.blog.163.com/blog/static/212388112011213407503/
View the currently used shell