查看當(dāng)前發(fā)行版可以使用的shell
[root@localhost ~]$ cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
查看當(dāng)前使用的shell方法
一、最常用的查看shell的命令,但不能實(shí)時(shí)反映當(dāng)前shell
[root@localhost ~]$ echo $SHELL
/bin/bash
二、下面這個(gè)用法并不是所有shell都支持
[root@localhost ~]$ echo $0
-bash
三、環(huán)境變量中shell的匹配查找
[root@localhost ~]$ env | grep SHELL
SHELL=/bin/bash
四、口令文件中shell的匹配查找
[root@localhost ~]$ cat /etc/passwd | grep root
root:x:0:0:root:/root:/bin/bash
五、查看當(dāng)前進(jìn)程
[root@localhost ~]$ ps
PID TTY TIME CMD
3052 pts/0 00:00:00 bash
3254 pts/0 00:00:00 ps
六、先查看當(dāng)前shell的pid,再定位到此shell進(jìn)程
[root@localhost ~]$ echo $$
1862
[root@localhost ~]$ ps -ef | grep 1862
root 1862 1860 0 01:50 pts/0 00:00:00 -bash
root 2029 1862 0 02:07 pts/0 00:00:00 ps -ef
root 2030 1862 0 02:07 pts/0 00:00:00 grep 1862
七、輸入一條不存的命令,查看出錯(cuò)的shell提示
[root@localhost ~]$ asdf
bash: asdf: command not found
附:一條命令即可實(shí)現(xiàn):
[root@localhost ~]$ ps -ef | grep `echo $$` | grep -v grep | grep -v ps
root 1862 1860 0 01:50 pts/0 00:00:00 -bash