教程集 www.jiaochengji.com
教程集 >  脚本编程  >  shell  >  正文 linux怎么查看当前shell

linux怎么查看当前shell

发布时间:2014-12-22   编辑:jiaochengji.com
本文介绍了linux查看当前shell的方法,linux系统中怎么查看当前shell,有关shell脚本的基础知识,有需要的朋友参考下。

分享六种查看linux当前shell的方法。
 
1、实时查看当前进程中使用的shell种类:推荐
 

复制代码 代码示例:
ps | grep $$ | awk '{print $4}'
(注:$$表示shell的进程号)

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

复制代码 代码示例:
$ echo $SHELL

3、更简洁,但并不是所有shell都支持
 

复制代码 代码示例:
$ echo $0

4、环境变量中shell的匹配查找
 

复制代码 代码示例:
env | grep SHELL

5、口令文件中shell的匹配查找
 

复制代码 代码示例:
cat /etc/passwd | grep muye

6、用ps -ef时
 

复制代码 代码示例:
$ ps -ef | grep $$ | grep -v grep | grep -v ps
 

注:grep -v 表示取反,如下:
 

<a href="mailto:muye@bupt:~$">muye@bupt:~$</a> ps -ef | grep $$
muye 4750 4745 0 15:47 pts/1 00:00:00 bash
muye 5331 4750 0 16:51 pts/1 00:00:00 ps -ef
muye 5332 4750 0 16:51 pts/1 00:00:00 grep --color=auto 4750
 

去掉后两个。

您可能感兴趣的文章:
linux怎么查看当前shell
更改linux用户登录shell的方法
有关linux子shell变量的相关知识
crontab调用shell无法读取环境变量的解决办法
inux shell初级入门教程
python脚本如何测试手机
linux怎么查看python的安装路径
bash shell脚本执行的几种方法
source命令执行shell文件与shell script文件名直接运行的区别
windows下shell脚本在linux执行出错怎么解决

关键词: linux shell  shell   
[关闭]
~ ~