文章目录
一、临时修改
- 以ls -a命令为例:
bash
[root@mysql ~]# alias la='ls -a'
[root@mysql ~]# la
. 1.sh .bash_logout .bashrc .cshrc .mysql_history .tcshrc
.. .bash_history .bash_profile .cache .history .ssh
二、永久修改
bash
[root@mysql ~]# echo "alias le='ls -la'" >> /etc/bashrc
[root@mysql ~]# source /etc/bashrc
[root@mysql ~]# le
total 52
dr-xr-x---. 4 root root 4096 Sep 26 11:12 .
dr-xr-xr-x. 20 root root 4096 Sep 23 16:27 ..
-rwxrwxrwx 1 root root 240 Sep 26 11:12 1.sh
-rw------- 1 root root 5072 Sep 26 17:09 .bash_history
-rw-r--r--. 1 root root 18 Oct 29 2019 .bash_logout
-rw-r--r--. 1 root root 176 Oct 29 2019 .bash_profile
-rw-r--r--. 1 root root 176 Oct 29 2019 .bashrc
drwx------ 3 root root 4096 May 18 2020 .cache
-rw-r--r--. 1 root root 100 Oct 29 2019 .cshrc
-rw------- 1 root root 0 May 18 2020 .history
-rw------- 1 root root 2113 Sep 23 20:50 .mysql_history
drwx------ 2 root root 4096 Sep 23 09:56 .ssh
-rw-r--r--. 1 root root 129 Oct 29 2019 .tcshrc
三、针对特定用户永久修改
bash
[root@mysql ~]# useradd -m pt
[root@mysql ~]# su - pt
[pt@mysql ~]$ echo "alias la='ls -la'" >> ~/.bashrc
[pt@mysql ~]$ source ~/.bashrc
[pt@mysql ~]$ la
total 24
drwx------ 2 pt pt 4096 Sep 26 17:04 .
drwxr-xr-x. 3 root root 4096 Sep 26 17:03 ..
-rw------- 1 pt pt 141 Sep 26 17:07 .bash_history
-rwxr-xr-x. 1 pt pt 75 Jan 10 2020 .bash_logout
-rwxr-xr-x. 1 pt pt 71 Mar 19 2020 .bash_profile
-rwxr-xr-x. 1 pt pt 156 Sep 26 17:06 .bashrc