zoukankan      html  css  js  c++  java
  • Linux下查看使用的是哪种shell的方法汇总 ----- 转载

    本文转载自: https://www.jb51.net/LINUXjishu/247797.html

    这篇文章主要介绍了Linux下查看使用的是哪种shell的方法汇总,本文总结了9种查看当前系统使用的是哪种shell的方法,需要的朋友可以参考下
     

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

    [root@localhost ~]$ cat /etc/shells
    /bin/sh
    /bin/bash
    /sbin/nologin

    查看当前使用的shell方法

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

    [root@localhost ~]$ echo $SHELL
    /bin/bash

    二、下面这个用法并不是所有shell都支持
     
    [root@localhost ~]$ echo $0
    -bash

    三、环境变量中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

    五、查看当前进程

    [root@localhost ~]$ ps
    PID TTY TIME CMD
    3052 pts/0 00:00:00 bash
    3254 pts/0 00:00:00 ps

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

    [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

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

    [root@localhost ~]$ asdf
    bash: asdf: command not found

    附:一条命令即可实现:

    [root@localhost ~]$ ps -ef | grep `echo $$` | grep -v grep | grep -v ps
    root 1862 1860 0 01:50 pts/0 00:00:00 -bash
  • 相关阅读:
    习题1
    实验3阅读下面程序、分析说明运行结果,并上机验证。
    实验2利用循环计算n个圆柱体体积。
    实验1编写求圆面积的程序,要求当输入的半径r<=0时,提示输入错误,要求r为浮点型,r的数值是动态的由键盘输入;
    例7-12
    例 7-11
    例7-9
    例7-8
    例7-7
    例7-6
  • 原文地址:https://www.cnblogs.com/hxing/p/11824943.html
Copyright © 2011-2022 走看看