alias 是一個設(shè)置別名的命令,例如:
alias cls= 'clear'
1.設(shè)置完成之后朴下,就可以用 cls 完成clear命令的清屏操作
但美中不足的·是,當(dāng)系統(tǒng)重啟之后就會失效苦蒿,所以要實現(xiàn)永久有效殴胧,則需要 修改用戶目錄下的一個文件 .bashrc
目錄為 ~/.bashrc
使用VIM編輯 ~/.bashrc這個文件
vim ~/.bashrc
2.打開后如下:
#.bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
3.加上我們的
alias cls=’clear’這行,并且加一個注釋# User specific aliases and functions
修改后如下
#.bashrc
# User specific aliases and functions
alias cls='clear'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
4.保存并退出VIM佩迟;
使用命令生效更改就完成了
source ~/.bashrc
5.重啟后团滥,試下應(yīng)該可以
也可以輸入命令查看所有別名
alias