bash shell 介绍
bash shell 是GNU 开发的一种命令解释器
bash shell 能做什么
执行方式
- 命令执行 处理简单事物
- 脚本执行 script 处理复杂事物
命令行介绍
[root@Zhang-linux ~]#
[test@Zhang-linux ~]$
- root 表示当前用户是超级管理员, root 的位置是当前用户
- @ 分隔符
- Zhang-linux 表示当前主机名
- ~ 表示当前用户的家目录, 位置表示当前所在目录位置
-
表示超级管理员提示符
- $ 表示普通用户提示符
命令行结构
[root@qls ~]# ls -l /root #命令+选项+参数
total 4
-rw-------. 1 root root 1271 Oct 23 12:20 anaconda-ks.cfg
- 命令
- [选项]
- [参数/路径]
中括号中的 可以省略
命令的报错信息
-
command not found 找不到命令
-
No such file or directory 没有这个文件或目录
-
选项
bash 特性
tab 补全
选项补全
[root@qls ~]# yum install -y bash-completion bash-completion-extra
[root@qls ~]# systemctl res
rescue reset-Failed restart
参数补全
可以自动补全路径.
命令别名
[root@qls ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
自定义别名
利用alias命令可以自定义别名
[root@qls ~]# alias wang='ping baidu.com'
[root@qls ~]# wang
PING baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=128 time=30.0 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=128 time=28.0 ms
别名和 环境变量配置
个人
[root@qls ~]# ll -a .bash*
-rw-r--r--. 1 root root 176 Dec 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 29 2013 .bashrc
这两个隐藏文件是配置别名和环境变量的
全局
[root@Zhang-linux ~]# ll /etc/profile
-rw-r--r--. 1 root root 1922 Oct 24 11:38 /etc/profile
[root@Zhang-linux ~]# ll /etc/profile.d/*.sh
[root@Zhang-linux ~]# ll /etc/bashrc
-rw-r--r--. 1 root root 2853 Oct 31 2018 /etc/bashrc
删除别名
命令 unalias + 别名
命令历史
输入命令 history 查看所有操作命令历史
删除命令记录 history -d + 编号
讲命令记录写入文件 history -w
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。