什麼是shellhtml
[root@lixiang01 ~]# yum list |grep zsh autojump-zsh.noarch 22.3.0-3.el7 epel zsh.x86_64 5.0.2-25.el7_3.1 updates zsh-html.x86_64 5.0.2-25.el7_3.1 updates zsh-lovers.noarch 0.9.0-1.el7 epel [root@lixiang01 ~]# yum list |grep ksh ksh.x86_64 20120801-26.el7 base mksh.x86_64 46-5.el7 base
[root@ax-01 ~]# history
修改命令歷史保存數量shell
[root@ax-01 ~]# echo $HISTSIZE //默認命令歷史最大1000條 1000 [root@ax-01 ~]# vim /etc/profile //能夠在此調整環境變量
[root@ax-01 ~]# source !$ source /etc/profile [root@ax-01 ~]# echo $HISTSIZE 5000
修改命令歷史顯示格式vim
[root@ax-01 ~]# HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S" [root@ax-01 ~]# history 2 2017/08/30 09:51:25echo $HISTSIZE 3 2017/08/30 09:51:44vim /etc/profile 4 2017/08/30 09:53:37echo $HISTSIZE [root@ax-01 ~]# !vim vim /etc/profile
[root@ax-01 ~]# source /etc/profile [root@ax-01 ~]# !echo echo $HISTTIMEFORMAT %Y/%m/%d %H:%M:%S
命令歷史永久保存bash
[root@ax-01 ~]# chattr +a .bash_history [root@ax-01 ~]# lsattr .bash_history -----a-------e-- .bash_history
歎號常見用法命令行
[root@ax-01 etc]# cd /etc/yum.repos.d/ [root@ax-01 yum.repos.d]# cd .. [root@ax-01 etc]# !! 再次執行上一條命令 cd .. [root@ax-01 /]# [root@ax-01 /]# cd [root@ax-01 ~]# history | tail -n4 1051 cd /etc/yum.repos.d/ 1052 cd .. 1053 cd 1054 history | tail -n4 [root@ax-01 ~]# !1051 //照history編號運行 cd /etc/yum.repos.d/
參數補全,rest
[root@ax-01 ~]# yum install -y bash-completion //安裝參數補全包,須要重啓 [root@ax-01 ~]# reboot [root@ax-01 ~]# systemctl restart network network-online.target network.service
alias別名code
[root@ax-01 ~]# alias renet='systemctl restart network' [root@ax-01 ~]# echo "alias renet='systemctl restart network'" >> .bashrc [root@ax-01 ~]# unalias renet 取消 [root@ax-01 ~]# vim .bashrc 刪除定義別名
實驗htm
[root@lixiang01 ~]# ls *txt* 1_heard.txt.bak 1.txt 22.txt 2.txt.bak test.txt word1.txt 記錄.txt [root@lixiang01 ~]# ls 1* 123.tar.bz2 1_heard.txt.bak 1.txt 111: 22.txt [root@lixiang01 ~]# ls ?.txt 1.txt [root@lixiang01 ~]# touch 2.txt [root@lixiang01 ~]# touch 3.txt [root@lixiang01 ~]# ls ?.txt 1.txt 2.txt 3.txt [root@lixiang01 ~]# ls [0-3].txt 1.txt 2.txt 3.txt [root@lixiang01 ~]# ls [123].txt 1.txt 2.txt 3.txt [root@lixiang01 ~]# ls [0-9].txt 1.txt 2.txt 3.txt [root@lixiang01 ~]# ls [0-9a-zA-Z].txt 1.txt 2.txt 3.txt [root@lixiang01 ~]# touch d.txt [root@lixiang01 ~]# ls [0-9a-zA-Z].txt 1.txt 2.txt 3.txt d.txt [root@lixiang01 ~]# ls {1,3,d}.txt 1.txt 3.txt d.txt
> 輸出重定向 >> 追加 2> 錯誤重定向,支持追加2>> &> 所有重定向,支持追加&>>
區分輸出正確與錯誤信息內存
[root@ax-01 ~]# cat /etc/passwd nosuchthing.txt > right.log 2> err.log [root@ax-01 ~]# cat err.log cat: nosuchthing.txt: No such file or directory