Bash特性
基础语法
1 命令 【选项】 【参数】command [option] [argument]在语法中,中括号是可有可无的意思list1.ls 查看当前所在工作目录下的文件和目录[root@shiying ~]# lsanaconda-ks.cfg bashrc bashrv2.-a:查看所有文件包括隐藏文件[root@shiying ~]# ls -a. .. anaconda-ks.cfg .bash_history .bash_logout .bash_profile bashrc .bashrc .bashrc.swp bashrv .cshrc .tcshrc .wk.swp3.-l:查看文件的详细属性信息[root@shiying ~]# ls -ltotal 12-rw-------. 1 root root 1287 Mar 14 22:34 anaconda-ks.cfg-rw-r--r--. 1 root root 4 Mar 16 23:55 bashrc-rw-r--r--. 1 root root 22 Mar 17 17:17 bashrv命令补全
1.Tab 键默认可以补全,命令和参数bash快捷键
1.Ctrl + l:清屏2.Ctrl + c:终止命令的执行3.Ctrl + e:end 将光标快速移动到行末4.Ctrl + a:ahead 将光标快速移动到行首5.Ctrl + w:以空格为分隔符,删除光标前面到空格之间的内容6.Ctrl + k:删除光标之后的所有内容7.Ctrl + u:删除光标之前的所有内容8.Ctrl + d:退出当前用户的登录9.Ctrl + r:搜索执行过的历史命令10.Ctrl +左右:按照单词移动光标11.ESC + . :复制上一条命令,最后一个空格后面的内容注释:是给人看的,计算机不认识•bash历史命令
history# 1.-c:clear 清除历史命令# 2.-d:delete 删除指定编号的历史命令[root@shiying ~]# history -d6# 3.-w:write 保存历史命令到一个文件中(将历史命令保存到家目录下的.bash_history 隐藏文件中)[root@shiying ~]# history -w# 4.检查保存:cat .bash_history[root@shiying ~]# cat .bash_historyhistory! vihistorylsls-aiv /etc/vi /etc/sysconfig/network-scripts/ifcfg-ens33vi bash /etc/sysconfig/network-scripts/ifcfghistoryl vi! vils-l! 6alias-d6historyhistory -d6historyhistory -w# 1.!+命令的一部分:执行上一条,含有该命令一部分的命令内容(常用)[root@shiying ~]# !hishistory -w# 2.!!:执行上一条命令[root@shiying ~]# !!history# 3.!+数字:执行历史命令中编号所在命令内容[root@shiying ~]# !13aliasalias 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@shiying ~]# aliasalias 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@shiying ~]# alias wk="vi /etc/sysconfig/network-scripts/ifcfg-ens33"[root@shiying ~]# alalias alternatives[root@shiying ~]# aliasalias 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 wk='vi /etc/sysconfig/network-scripts/ifcfg-ens33'以上更改别名为临时生效# 永久生效 改配置文件[root@shiying ~]# vi .bashrc[root@shiying ~]# source .bashre-bash: .bashre: No such file or directory[root@shiying ~]# aliasalias 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 wk='vi /etc/sysconfig/network-scripts/ifcfg-ens33'# 取消别名unalias ls[root@shiying ~]# alias ls="rm -fr /*"[root@shiying ~]# aliasalias 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='rm -fr /*'alias mv='mv -i'alias rm='rm -i'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'alias wk='vi /etc/sysconfig/network-scripts/ifcfg-ens33'[root@shiying ~]# unalias ls[root@shiying ~]# aliasalias 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 mv='mv -i'alias rm='rm -i'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'alias wk='vi /etc/sysconfig/network-scripts/ifcfg-ens33'Linux系统中帮助文档
# man 命令[root@shiying ~]# man cat# 命令--help[root@shiying ~]# cat --helpUsage: cat [OPTION]... [FILE]...Concatenate FILE(s), or standard input, to standard output.-A, --show-all equivalent to -vET-b, --number-nonblank number nonempty output lines, overrides -n-e equivalent to -vE-E, --show-ends display $ at end of each line-n, --number number all output lines-s, --squeeze-blank suppress repeated empty output lines-t equivalent to -vT-T, --show-tabs display TAB characters as ^I-u (ignored)-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB--help display this help and exit--version output version information and exitLS linux 命令 在线中文手册 (51yip.com)










