- 命令补全
命令补全:若给出的字符能在系统命令文件中被唯一标识,则tab键直接补全,否则,会给出相应的列表
[root@host ~]# echo $PATH #查看当前的环境变量
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:
[root@host ~]# cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
[root@host ~]# echo $SHELL #当前系统默认的shell
/bin/bash
配置环境变量的文件有:
全局变量:/etc/bashrc ; /etc/profile
用户变量:~/.bashrc ; ~/.bash_profile
例如:配置一个全局变量:hello 命令,显示:hello world
[root@host ~]# mkdir -p /test/test_bin/ #创建一个存放hello文件的目录
[root@host ~]# cd /test/test_bin/
[root@host test_bin]# touch hello
[root@host test_bin]# chmod +x hello #给hello文件赋权,可执行
[root@host test_bin]# vim hello
echo "hello world!"
root@host test_bin]# vim /etc/profile #配置/etc/profile
export PATH=$PATH:/test/test_bin #在末尾找个位置加上这句就可以了
[root@host test_bin]# source /etc/profile #source 一下/etc/profile 可以使这个文件立即生效不用重启
[root@host test_bin]# hel #此时已经可以用补全机制 获取到hello命令了
hello help
[root@host test_bin]# hello
hello world!
[root@host ~]# he #在root家目录也可以补全hello命令
head hello help hexdump
[root@host ~]# echo $PATH #查看此时的环境变量,已经有/test/test_bin了
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/test/test_bin
- 路径补全
路径补全:给出的路径字符,若能够被文件系统位移匹配,则直接补全,若存在多个,则给出相应列表
[root@host ~]# cat /etc/f #给出的路径字符对应目录下查找,进行补全
favicon.png filesystems firewalld/ fonts/ fstab fuse.conf
-------------------------------------------------------------------------------------------------------返回目录