Linux查看shell類型


原文鏈接:http://babybandf.blog.163.com/blog/static/6199353201051914119604/
 
一、查看當前發行版可以使用的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
二、查看當前使用的shell : 
chao@chao:~$ echo $0
bash
三、查看當前用戶(默認)使用的shell:
chao@chao:~$ echo $SHELL
/bin/bash
四、環境變量中shell的匹配查找
chao@chao:~$ env | grep SHELL
SHELL=/bin/bash
五、口令文件中shell的匹配查找
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
七、先查看當前shell的pid,再定位到此shell進程

 

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下可能略又不同。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM