原文鏈接:http://babybandf.blog.163.com/blog/static/6199353201051914119604/
一、查看當前發行版可以使用的shell:
二、查看當前使用的shell :
三、查看當前用戶(默認)使用的shell:
四、環境變量中shell的匹配查找
五、口令文件中shell的匹配查找
六、查看當前進程
七、先查看當前shell的pid,再定位到此shell進程
chao@chao:~$ cat /etc/shells # /etc/shells: valid login shells /bin/csh /bin/sh /usr/bin/es /usr/bin/ksh /bin/ksh /usr/bin/rc /usr/bin/tcsh /bin/tcsh /usr/bin/esh /bin/dash /bin/bash /bin/rbash /usr/bin/screen
chao@chao:~$ echo $0 bash
chao@chao:~$ echo $SHELL /bin/bash
chao@chao:~$ env | grep SHELL SHELL=/bin/bash
chao@chao:~$ cat /etc/passwd | grep chao chao:x:1000:1000:chao,340,6733,6733:/home/chao:/bin/bash
chao@chao:~$ ps PID TTY TIME CMD 4507 pts/0 00:00:00 bash 8688 pts/0 00:00:00 ps
chao@chao:~$ echo $$ 4507 chao@chao:~$ ps -ef |grep 3052 chao 8710 4507 0 15:30 pts/0 00:00:00 grep --color=auto 3052
附:一條命令即可實現:
chao@chao:~$ ps -ef |grep `echo $$` |grep -v grep |grep -v ps chao 4507 4505 0 09:30 pts/0 00:00:00 bash
另:有網友說可以輸入一個不存在命令就可以顯示當前shell類型,不過我測試的結果是顯示不了,如下:
chao@chao:~$ dfsdfsas
dfsdfsas: command not found
但是2010-03-30 在一台sun小機上的solaris上測試這個方法是可以的~~
BTW:以上均是在ubuntu9.10下測試的結果,不同linux之間、不同當前shell下可能略又不同。