国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 >

    Linux下怎么查看使用的是哪種shell

    時間: 加城1195 分享

      Linux繼承了Unix以網(wǎng)絡(luò)為核心的設(shè)計思想,是一個性能穩(wěn)定的多用戶網(wǎng)絡(luò)操作系統(tǒng)。很多操作我們可以用命令實現(xiàn),比如查看shell版本信息等,這篇文章主要介紹了Linux下查看使用的是哪種shell的方法匯總,本文總結(jié)了9種查看當(dāng)前系統(tǒng)使用的是哪種shell的方法,需要的朋友可以參考下

      查看當(dāng)前發(fā)行版可以使用的shell

      復(fù)制代碼代碼如下:

      [root@localhost ~]$ cat /etc/shells

      /bin/sh

      /bin/bash

      /sbin/nologin

      查看當(dāng)前使用的shell方法

      一、最常用的查看shell的命令,但不能實時反映當(dāng)前shell

      復(fù)制代碼代碼如下:

      [root@localhost ~]$ echo $SHELL

      /bin/bash

      二、下面這個用法并不是所有shell都支持

      復(fù)制代碼代碼如下:

      [root@localhost ~]$ echo $0

      -bash

      三、環(huán)境變量中shell的匹配查找

      復(fù)制代碼代碼如下:

      [root@localhost ~]$ env | grep SHELL

      SHELL=/bin/bash

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

      復(fù)制代碼代碼如下:

      [root@localhost ~]$ cat /etc/passwd | grep root

      root:x:0:0:root:/root:/bin/bash

      五、查看當(dāng)前進程

      復(fù)制代碼代碼如下:

      [root@localhost ~]$ ps

      PID TTY TIME CMD

      3052 pts/0 00:00:00 bash

      3254 pts/0 00:00:00 ps

      六、先查看當(dāng)前shell的pid,再定位到此shell進程

      復(fù)制代碼代碼如下:

      [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提示

      復(fù)制代碼代碼如下:

      [root@localhost ~]$ asdf

      bash: asdf: command not found

      附:一條命令即可實現(xiàn):

      復(fù)制代碼代碼如下:

      [root@localhost ~]$ ps -ef | grep `echo $$` | grep -v grep | grep -v ps

      root 1862 1860 0 01:50 pts/0 00:00:00 -bash

      補充:Linux基本命令

      ①ls 意為list 列出當(dāng)前文件夾中的文件

      -l 顯示文件的屬性 可用ll來表示

     ?、赼lias 別名 看看是否有別名的文件

     ?、踓d dir 跳躍目錄 -P選項 將路徑中的鏈接文件替換成鏈接指向的文件路徑

     ?、躳wd 查看當(dāng)前工作的文件夾名 使用-P的選項,會直接進入到其中,相當(dāng)于cd

      相關(guān)閱讀:Linuxshell腳本不執(zhí)行問題實例分析

      shell腳本不執(zhí)行問題:某天研發(fā)某同事找我說幫他看看他寫的shell腳本,死活不執(zhí)行,報錯。我看了下,腳本很簡單,也沒有常規(guī)性的錯誤,報“:badinterpreter:Nosuchfileordirectory”錯。看這錯,我就問他是不是在windows下編寫的腳本,然后在上傳到linux服務(wù)器的……果然。原因:在DOS/windows里,文本文件的換行符為rn,而在*nix系統(tǒng)里則為n,所以DOS/Windows里編輯過的文本文件到了*nix里,每一行都多了個^M。解決:

      1)重新在linux下編寫腳本;

      2)vi:%s/r//g:%s/^M//g(^M輸入用Ctrl+v,Ctrl+m)附:sh-x腳本文件名,可以單步執(zhí)行并回顯結(jié)果,有助于排查復(fù)雜腳本問題。


    Linux下查看使用的是哪種shell相關(guān)文章:

    1.Linux下最常用的Shell命令的介紹

    2.xshell操作linux系統(tǒng)的常用命令

    3.linux shell獲取當(dāng)前時間命令

    4.linux shell腳本執(zhí)行命令

    5.linux shell的cat命令詳解

    4017046