加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell介绍、命令历史、命令补全和别名、通配符、输入输出重定向

发布时间:2020-12-15 09:20:02 所属栏目:安全 来源:网络整理
导读:shell介绍 shell是一个命令解释器,提供用户和机器之间的交互,支持特定语法,比如逻辑判断、循环,每个用户都可以有自己特定的shell CentOS7默认shell为bash(Bourne Agin Shell) 还有zsh、ksh等 命令历史 查看历史命令 [root@test76 ~]# cat .bash_history

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读