linux修改命令别名的方式


一、临时修改

  • 以ls -a命令为例:
[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

二、永久修改

[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

三、针对特定用户永久修改

[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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

十一的学习笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值