Linux-shell-1

7.Shell

本章同步視頻:https://edu.51cto.com/sd/e4874

7.1 Shell

        Shell 是一個用 C 語言編寫的程序,它是用戶使用 Linux 的橋樑。Shell 既是一種命令語言,又是一種程序設計語言。Shell 是指一種應用程序,這個應用程序提供了一個界面,用戶通過這個界面訪問操作系統內核的服務。Ken Thompson 的 sh 是第一種 Unix Shell,Windows Explorer 是一個典型的圖形界面 Shell。

7.1.1 Linux中合法的shell

[root@localhost mnt]# cat /etc/shells

/bin/sh         #已經被 /bin/bash 所取代

/bin/bash       # Linux 預設的 shell

/sbin/nologin

/usr/bin/sh       

/usr/bin/bash

/usr/sbin/nologin

/bin/tcsh

/bin/csh        #已經被 /bin/tcsh所取代

7.1.2 Shell的功能

n  命令編修能力 (history)

n  命令與檔案補全功能: ([tab] 按鍵的好處)

n  命令別名設定功能: (alias)

n  工作控制、前景背景控制: (job control, foreground, background)

n  通配符: (Wildcard)

n  程序化腳本: (shell scripts)

7.1.3 查詢指令是否爲 Bash shell 的內建命令: type

1.語法

[dmtsai@study ~]$ type [-tpa] name

選項與參數:

:不加任何選項與參數時,type 會顯示出 name 是外部指令還是 bash 內建指令

-t  :當加入 -t 參數時,type 會將 name 以底下這些字眼顯示出他的意義:

      file    :表示爲外部指令;

      alias   :表示該指令爲命令別名所設定的名稱;

builtin:表示該指令爲 bash 內建的指令功能;

-p  :如果後面接的 name 爲外部指令時,纔會顯示完整文件名;

-a  :會由 PATH 變量定義的路徑中,將所有含 name 的指令都列出來,包含 alias

2.用法

[root@localhost mnt]# type ls

ls is aliased to `ls --color=auto'

[root@localhost mnt]# type -t ls

alias

[root@localhost mnt]# type -a ls

ls is aliased to `ls --color=auto'

ls is /usr/bin/ls

ls is /bin/ls

[root@localhost mnt]# type cd

cd is a shell builtin


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章