shell介绍、命令历史、命令补全和别名、通配符、输入输出重定向
shell介绍 shell是一个命令解释器,提供用户和机器之间的交互,支持特定语法,比如逻辑判断、循环,每个用户都可以有自己特定的shell CentOS7默认shell为bash(Bourne Agin Shell) 还有zsh、ksh等 命令历史 查看历史命令 [root@test76 ~]# cat .bash_history 修改历史记录条数: vi /etc/profile HISTSIZE=1000 修改查看历史记录的格式: /etc/profile中新增: HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S " source/etc/profile 841 2017/10/20 06:01:05 vi .bash_history 842 2017/10/20 06:02:03 vi /etc/profile 843 2017/10/20 06:03:23 source /etc/profile 844 2017/10/20 06:03:27 history 加入权限控制: [root@test76 ~]# chattr +a .bash_history [root@test76 ~]# > .bash_history -bash: .bash_history: Operation not permitted !!:表示执行上条命令 !844:表示执行844行的命令 !his:表示执行his开头的命令,是最近一次执行的his开头的 命令补全和别名 1、tab补全 2、参数补全 安装bash-completion alias 别名 [root@test ~]# alias wo='ls /root' #临时有效 [root@test ~]# wo 2.txt 2.txt.bz2 anaconda-ks.cfg 永久有效: [root@test ~]# vi .bashrc # .bashrc # User specific aliases and functions alias wo='ls /root' 通配符 1、[root@test ~]# ls *.txt 2.txt david.txt 2、 [root@test ~]# ls ?.txt 2.txt [root@test ~]# ls ??.txt 23.txt [root@test ~]# ls [0-9].txt 2.txt [root@test ~]# ls [0-9][0-9].txt 23.txt [root@test ~]# ls {2,23}.txt 23.txt 2.txt 重定向: cat 1.txt >2.txt cat 1.txt >> 2.txt [root@test ~]# cat 23.txt >> 2.txt &>/dev/null (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |