1、修改 .bashrc
[root@hadoop121 ~]# cd
[root@hadoop121 ~]# vim .bashrc
shopt -s autocd
什么是 .bashrc ?
.bashrc 是一個(gè) shell 腳本,每次用戶以交互模式打開(kāi)新 shell 時(shí)都會(huì)運(yùn)行該腳本。
你可以在該文件中添加要在命令提示符下輸入的任何命令垛吗。
.bashrc 文件本身包含終端會(huì)話的一系列配置。包括設(shè)置和啟用:著色烁登、補(bǔ)全怯屉,shell 歷史,命令別名等
2饵沧、重新加載修改后的文件 .bashrc
[root@hadoop121 ~]# source ~/.bashrc
3蚀之、不使用cd 進(jìn)入目錄
[root@hadoop121 ~]# /
cd /
[root@hadoop121 /]# /opt/module/
cd /opt/module/
[root@hadoop121 module]#
4、開(kāi)啟 autocd
[root@hadoop121 module]# shopt -s autocd
5捷泞、查看狀態(tài)
[root@hadoop121 module]# shopt | grep autocd
autocd on
6足删、關(guān)閉 autocd
[root@hadoop121 module]# shopt -u autocd