3. Shell基础知识
3.1 Shell的由来
3.1.1 Bourne Agin Shell
3.1.2 其他的shell, 有 zsh, ksh等
3.2 查看有没有shell
3.2.1 yum list | grep zsh
3.2.2 ls /root/.bash_history
3.2.3 echo $HISTSIZE -> vi /etc/profile 修改HISTSIZE的值 -> source /etc/profile
3.2.4 history -c //清空命令历史(内存中的)
3.2.5 HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S"
3.2.6 vi /etc/profile
3.2.7 chattr +a ~/.bash_history //只能被追加,不会被删除
3.2.8 !! //最后一条命令; !n // !words //
3.3 安装参数补全源
3.3.1 yum install -y bash-completion //安装参数补全源后需要重启电脑(reboot)才生效
3.3.2 systemctl restart network.service //重启网络服务
3.3.3 rpm -qa bash-completion
3.4 alias 配置文件
3.4.1 vi .bashre //alias的配置文件(一部分)
3.4.2 cd /etc/profile.d/ //alias其他的一部分配置文件
3.4.3 Tab键:
3.4.3.1 按一下匹配命令和参数
3.4.3.2 按两下显示匹配信息供选择
3.5 通配符
3.5.1 * 匹配所有字符 ls *.txt
3.5.2 ? 匹配一个字符 ls ?.txt
3.5.3 ls [0-9].txt
3.5.4 ls {1,2}.txt
3.5.5 重定向 cat 1.txt > 2.txt
3.5.6 追加重定向 cat 1.txt >> 2.txt
3.5.7 错误重定向 lsaaa 2> a.txt
3.5.8 追加错误重定向 lsaaa 2>> a.txt
3.5.9 wc -l < 1.txt //输入重定向,wc -l查看文本行数;左边需要是命令
3.5.10 ls [12].txt aaa.txt &> a.txt //&> 为正确错误重定向
3.5.11 ls [12].txt aaa.txt >1.txt 2>a.txt //将正确的和错误的区分开
3.6 管道符和作业控制
3.6.1 cat 1.txt | wc -l
3.6.2 cat 1.txt | grep ‘aaa‘
3.6.3 ctrl + z //暂停一个任务
3.6.4 df -h //查看磁盘使用量
3.6.5 fg //前台frontGround
3.6.5.1 fg IDNumber
3.6.6 jobs //查看后台或已停止的任务
3.6.7 bg //后台background
3.6.7.1 bg IDNumber
3.6.8 vmstate 1 //动态的显示系统状态
3.6.9 sleep 100 //暂停100秒
3.6.9.1 sleep 100 & //把命令放到后台运行
3.6.9.2 ps aux| grep sleep //查看进程原文地址:http://aichannel.blog.51cto.com/12329802/1965998