③ linux基础bash shell特性 tab alias 快捷键

1 命令补全

ps: tab键可以实现命令还有参数及路径补全 加快命令输入速度 还有减少路径输入错误带来的麻烦
安装tab补全工具

yum install bash-completion
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base                                                                    | 3.6 kB  00:00:00     
docker-ce-stable                                                        | 3.5 kB  00:00:00     
epel                                                                    | 4.7 kB  00:00:00     
extras                                                                  | 2.9 kB  00:00:00     
(1/2): epel/x86_64/updateinfo                                           | 1.0 MB  00:00:00     
(2/2): epel/x86_64/primary_db                                           | 6.9 MB  00:00:01     
Package 1:bash-completion-2.1-8.el7.noarch already installed and latest version
Nothing to do
2 命令的快捷键 快捷键可以帮助我们大大提升工作效率
ctrl + a 快速到达命令行头部
ctrl + e 快速到达命令行尾部
ctrl + u 从光标的位置删除内容到头部
ctrl + k 从光标的位置删除内容到尾部
ctrl + w 以空格为单位 快速从命令行尾部删除内容到头部
ctrl + c 中断输入 及终止正在运行命令执行
ctrl + l 清屏 clear
ctrl + d 退出服务器
ctrl + 方向 以空格为单位 快速跳
3 历史记录history

选项:
-w 保存历史命令到文件

cat .bash_history

-c 清除命令记录
-d 删除一行命令

history -d 1006
4 命令别名 alias

1 如何设定别名

[root@rstx-53 opt]# alias ifnet=' vi /etc/sysconfig/network-scripts/ifcfg-eth0'
[root@rstx-53 opt]# ifnet

2 取消别名

[root@rstx-53 opt]# unalias ifnet
[root@rstx-53 opt]# ifnet
-bash: ifnet: command not found

3 系统为什么存在别名
提示命令有风险 防止误操作
PS: 当前命令都是临时生效
永久生效需写在 /etc/bashrc文件里面 . /etc/bashrc
4 命令帮助
help man

ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
  -b, --escape               print C-style escapes for nongraphic characters
      --block-size=SIZE      scale sizes by SIZE before printing them; e.g.,

man ls

http://linux.51yip.com/search
https://man.linuxde.net/

原文地址:https://www.cnblogs.com/yangtao416/p/14446953.html