history
history:Display or mainpulate the history list。顯示或操作歷史列表
-c: 清除歷史條目 清空的只是內存中的歷史
-d:刪除歷史中指定的命令
#:顯示歷史最近的#條歷史
-a:追加本次會話新執行的命令歷史表至歷史文件
-n:度歷史文件中爲讀過的行到歷史列表 只讀沒有讀過的命令
-r:讀歷史文件附加到歷史列表 全部重新讀取一遍
-w:保存歷史文件到指定的歷史文件
-p:展開歷史參數成多個行,但不存在歷史列表中 不儲存
-s: 展開歷史參數成一行,附加在歷史列表後 僞造歷史命令。
history 命令的變量
[root@localhost ~]# echo $HISTSIZE 默認是1000條 1000 [root@localhost ~]# echo $HISTFILE 默認是~/.bash_history /root/.bash_history [root@localhost ~]# echo $HISTFILESIZE 默認是1000條 1000
HISTTIMEFORMAT:歷史列表時間格式
[root@localhost ~]# history 5 183 history 184 clear 185 HISTTIMEFORMAT="" 186 history 187 history 5 [root@localhost ~]# HISTTIMEFORMAT="%F %T " 設置時間格式爲%F %T 注意T後面加空格不然會太緊湊 [root@localhost ~]# history 5 185 2016-07-30 16:04:29 HISTTIMEFORMAT="" 186 2016-07-30 16:04:32 history 187 2016-07-30 16:04:47 history 5 188 2016-07-30 16:05:08 HISTTIMEFORMAT="%F %T " 189 2016-07-30 16:05:13 history 5
HISTIGNORE:忽略所指定的命令
[root@localhost ~]# HISTIGNORE="tty:pwd:loo" 忽略tty:pwd:loo等字符串(錯誤代碼也可以,用:分隔) [root@localhost ~]# tty /dev/pts/0 [root@localhost ~]# pwd /root [root@localhost ~]# loo -bash: loo: command not found [root@localhost ~]# history 10 126 ls 127 history 128 cleat 129 history 10 130 HISTIGNORE="tty:pwd:loo" 131 history 132 clear 133 history 10 134 HISTIGNORE="tty:pwd:loo" 135 history 10 最近10條歷史中沒有顯示pwd,tty和loo
HISTCONTROL:歷史的記錄方式
HISTCONTROL="ignorestring:ignorestring" 連續命令用 :分隔
ignoredups:忽略重複的命令;連續且相同方爲"重複",HISTCONTROL默認使用。
ignorespace:忽略所有以空白開頭的命令
ignoreboth: ignoredups,ignorespace
erasedups:刪除"重複"命令 不連續且相同的"重複"命令
歷史文件存放路徑及配置文件: 環境變量也可寫在配置文件中
/etc/profile :全局配置文件,對所有用戶有效
~/.bash_profile:個人配置文件,只對個人用戶有效 (個人配置優先級高於全局)
~/.bash_history:歷史文件存放位置
調用歷史參數
!n:^:調用第N條命令的第一個參數
!n:$:調用第n條命令的最後一個參數
!m:n:調用第m條命令的第n個參數
!n:*:調用第n條命令的所有參數
!mk: 調用以mk開頭的命令
!?up:調用包含up字符的命令
Esc . :調用上次命令最後參數
Esc+ . :同上
^p :同上
!!:同上
page up鍵:同上
screen
系統管理員如果要做一些長時間的任務,比如系統備份、ftp長時間任務使用。它能讓多個用戶從不同的終端鏈接到一個會話,完成屏幕共享
首先使用rpm -q screen查看自己是否安裝screen軟件安裝包
[root@localhost ~]# rpm -q screen package screen is not installed # 表示screen軟件未安裝
如果沒有安裝,掛載光盤安裝screen-4.1.0-0.21.20120314git3c2946.el7.x86_64程序包
rpm -ivh /dev/cdrom/Package/screen-4.1.0-0.21.20120314git3c2946.el7.x86_64(如果掛載到/media/cdrom)
[root@localhost /]# mkdir /media/cdrom #創建目錄好方便掛載 [root@localhost /]# mount /dev/cdrom /media/cdrom #手動掛載 mount: block device /dev/sr0 is write-protected, mounting read-only [root@localhost /]# rpm -i /media/cdrom/Packages/screen-4.0.3-19.el6.x86_64.rpm #安裝screen軟件 warning: /media/cdrom/Packages/screen-4.0.3-19.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY #警告你沒有祕鑰,無須在意仍可用。
scree -S [SESSION] :打開新的會話
screen -x [SESSION]:加入會話
exit:結束當前會話
screen+a,d :退出當前會話
screen -ls :顯示所有會話
screen -r [SESSION]:恢復某會話
screen -d 讓Attached變成Detached 才能恢復連接狀態
只顯示目錄下的子目錄
只顯示隱藏文件