查看当前发行版可以使用的shell

[root@localhost ~]# cat /etc/shells
输出

# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/bin/zsh
/usr/bin/zsh

查看当前使用的shell

一、最常用的查看shell的命令,但不能实时反映当前shell
echo $SHELL

/usr/bin/zsh

二、下面这个用法并不是所有shell都支持
echo $0

-zsh

三、环境变量中shell的匹配查找
env | grep SHELL

SHELL=/usr/bin/zsh

四、口令文件中shell的匹配查找
cat /etc/passwd | grep root

root:x:0:0:root:/root:/usr/bin/zsh

五、查看当前进程
ps

    PID TTY          TIME CMD
 377834 pts/1    00:00:00 zsh
 377874 pts/1    00:00:00 ps

六、先查看当前shell的pid,再定位到此shell进程
echo $$

377834

ps -ef | grep 377834

root      377834  377800  0 07:17 pts/1    00:00:00 -zsh
root      377879  377834  0 07:24 pts/1    00:00:00 ps -ef
root      377880  377834  0 07:24 pts/1    00:00:00 grep 377834

附:一条命令即可实现:
ps -ef | grep `echo $$` | grep -v grep | grep -v ps

root      377834  377800  0 07:17 pts/1    00:00:00 -zsh

七、输入一条不存的命令,查看出错的shell提示
tom

zsh: tom: command not found
Logo

更多推荐