設置 臨時 alias
alias ll="ls -al"
缺點是下次登錄時就不生效了
永久生效解決方案
進入到 etc 文件夾下
cd /etc/
創建 bash_aliases 文件
vim bash_aliases
填寫 別名命令,如有需要可以填寫自己的別名命令
alias gohome="cd ~"
alias ll="ls -al"
按 ESC 輸入 :wq 保存文件
修改 bash.bashrc 文件
vim /etc/bash.bashrc
光標移至最下面粘貼如下代碼 (參考博文)
if [ -f /etc/bash_aliases ]; then
. /etc/bash_aliases
fi
按 ESC 輸入 :wq 保存文件
執行 source ~/.bashrc 立即生效
如果沒生效
執行 reboot 重啟(注:服務器不要隨意執行)
重新登錄
C:\Users\admin>ssh root@10.98.193.96
root@10.98.193.96's password:
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-52-generic x86_64)
輸入 ll
顯示
root@iZs9kgd0x5xmhaZ:~# ll
total 108
drwx------ 14 root root 4096 Jul 22 16:13 .
drwxr-xr-x 22 root root 4096 Jul 22 13:59 ..
drwxr-xr-x 3 root root 4096 Jul 18 10:25 .aspnet
-rw------- 1 root root 6241 Jul 22 16:13 .bash_history
-rw-r--r-- 1 root root 83 Jul 22 14:25 .bash_profile
參考文章:
