基礎命令:
外部命令:
可執行程式的檔名(基名);
命令直譯器:詞法分析、語法分析;
搜尋路徑:$path環境變數;
命令別名(bash的特性之一):
獲取當前使用者可用的別名的定義:
~]# alias
定義別名:
~]# alias name='command'
生命週期:當前shell程序;
撤消別名:
~]# unalias name
如果別名與命令名相同時,直接呼叫原命令,而非別名,可使用"\command"
bash的特性之二:命令歷史
shell程序會儲存其會話中使用者曾經執行過的命令;命令通過其「歷史檔案」來持久儲存此前執行過的命令;每個使用者都有其自己專用的歷史檔案;
histsize:shell程序的緩衝區保留的歷史命令的條數;
histfilesize:命令歷史檔案可儲存的歷史命令的條數;
預設均為1000;
histfile:當前使用者的命令歷史檔案;
~/.bash_history
檢視命令歷史列表:
~]# history
命令用法:
history -c:清空命令歷史;
history -d offset:刪除指定的條目;
-a 將當前緩衝的歷史行追加到歷史檔案中
-n 從歷史檔案中讀取所有未被讀取的行
-r 讀取歷史檔案並將內容追加到歷史列表中
呼叫命令歷史列表中的命令以重執行之目的:
!#:再一次執行歷史列表中的第#條命令;
!string:再一次執行命令歷史列表中最近乙個以指定的string開頭的命令;
快捷鍵:esc, .
alt+.
!$:給出的字元組合
顯示最近的n條件命令歷史:
history #
控制命令歷史的記錄方式:
通過histcontrol環境變數進行,其取值:
ignoredups:忽略重複的命令;重複是指連續且相同的命令;
ignorespace:以空白字元開頭的命令不記入歷史;
ignoreboth:上述兩者同時生效;
修改變數值的方式:
name='value'
bash特性之三:快捷鍵
ctrl+a:跳至命令列首;
ctrl+e:跳至命令行尾;
ctrl+k:刪除游標所在處至尾部的內容;
ctrl+u:刪除行首至游標所在處的內容;
常用命令:
shutdown:
shutdown [options...] [time] [wall...]
選項:-h:關機
-r:重啟
-c:取消尚未執行的關機或重啟操作
time:
(1) hh:mm
(2) +m
系統關機或重啟命令:
關機:halt, poweroff, init 0, systemctl poweroff, systemctl halt
重啟:reboot, init 6, systemctl reboot
which:
which - shows the full path of (shell) commands.
which [options] [programs]
-a:顯示所有匹配的程式檔案,而非第乙個;
--skip-alias:略過別名;
whereis:
whereis - locate the binary, source, and manual page files for a command
whereis [options] name...
-b search only for binaries
-m search only for manuals
who:
who - show who is logged on
who [option]...
-r:顯示執行級別;
-b:系統本次啟動的時間;
w:w - show who is logged on and what they are doing.
w [options] user [...]
whoami:
whoami - print effective userid
Bash 常用命令學習
type 怎麼知道這個指令是來自於外部指令 指的是其他非bash 所提供的指令 或是內建在bash 當中的呢?嘿嘿!利用type 這個指令來觀察即可 選項與引數 不加任何選項與引數時,type 會顯示出name 是外部指令還是bash 內建指令 t 當加入 t 引數時,type 會將name 以底下...
bash基本特性及基礎命令
3.路徑補全 4.命令列展開 5.命令的執行狀態 結果 二 目錄管理類命令 三 文字檔案檢視類命令 四 檔案的時間戳管理工具 環境變數 histsize 命令歷史記錄的條數 histfile bash history histfilesize 命令歷史檔案記錄歷史的條數 建議使用 esc,先按esc...
Git基礎及常用命令
git 開源的分布式版本控制系統。程式設計師必備。linux下git的安裝與配置 安裝 ubuntu下可以執行以下命令安裝 sudo apt install git,安裝成功後可檢視git版本 git version。git配置 git 提供了乙個叫做 git config 的工具,專門用來配置或讀...