当前位置: 首页 > article >正文

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

http://www.kler.cn/news/327838.html

相关文章:

  • 【学习笔记】手写 Tomcat 六
  • 每天五分钟深度学习框架pytorch:激活函数在神经网络中的应用
  • 修改ID不能用关键字作为ID校验器-elementPlus
  • 【Java】虚拟线程与Java 8普通线程池的对比
  • PHP反序列化1(基础入门)
  • 单片机内存保护-MPU(Memory Protection Unit)
  • 【最新华为OD机试E卷-支持在线评测】字符串变换最小字符串(100分)多语言题解-(Python/C/JavaScript/Java/Cpp)
  • CSS | 面试题:你知道几种移动端适配方案?
  • Git常用方法——详解
  • 【解密 Kotlin 扩展函数】扩展属性与扩展函数类似(十九)
  • 网络协议 TCP、UDP 和 HTTP
  • 解决QWidget及内部控件只能放大不能缩小的问题
  • Vscode: reason: oom, code: -536870904
  • VBA数据库解决方案第十五讲:Recordset集合中单个数据的精确处理
  • 【无标题】observer: error while loading shared libraries: libmariadb.so.3处理办法
  • 以串口接口为例介绍关于BSP底层架构开发的迭代过程
  • LeetCode 983.最低票价
  • 前端面试:项目细节重难点问题分享(17)
  • 无环SLAM系统集成后端回环检测模块(loop):SC-A-LOAM以及FAST_LIO_SLAM
  • 基于MTK7981平台,学习了解理解SoC上电和boot流程
  • Thinkphp/Laravel基于vue的的出版社书籍阅读管理系统
  • Docker笔记-Docker磁盘空间清理
  • c#中的功能优势
  • 【QT Quick】基础语法:文件定义类型与枚举类型
  • 最大正方形 Python题解
  • windows下安装nginx和基本配置
  • cfg80211是怎么配置无线设备的AP的?
  • Python与MongoDB交互
  • 《一本书讲透Elasticsearch》读书笔记-索引
  • 2024年主流前端框架的比较和选择指南