如何使用alias永久别名(linux篇)

一、alias的使用

alias主要作用是起一个别名的用处

它又分两种形式:

        ① 临时别名

        ② 永久别名

1.第一种(临时别名):

C:\Users\62452>ssh root@192.168.0.102
root@192.168.0.102's password:
Last login: Sat Jun 15 16:30:12 2024
[root@localhost ~]# clear
[root@localhost ~]# alias md='mkdir'
[root@localhost ~]# cd Desktop/
[root@localhost Desktop]# ls
demo  demo.txt  xxx.txt
[root@localhost Desktop]# md xxx
[root@localhost Desktop]# ls
demo  demo.txt  xxx  xxx.txt
[root@localhost Desktop]# exit
登出
Connection to 192.168.0.102 closed.
C:\Users\62452>ssh root@192.168.0.102
root@192.168.0.102's password:
Last login: Sat Jun 15 16:35:49 2024 from 192.168.0.103
[root@localhost ~]# cd Desktop/
[root@localhost Desktop]# md ttt
bash: md: 未找到命令...

2.第二种(永久别名)

/etc/bashrc或者.bashrc中添加所要修改的别名,因为终端连上后就可以直接运行这两个文件

C:\Users\62452>ssh root@192.168.1.102
root@192.168.1.102's password:
Last login: Sat Jun 15 16:51:08 2024 from 192.168.1.101
[root@localhost ~]# cd Desktop/
[root@localhost Desktop]# ls
demo  demo.txt  xxx  xxx.txt
[root@localhost Desktop]# md ttt
[root@localhost Desktop]# ls
demo  demo.txt  ttt  xxx  xxx.txt
[root@localhost Desktop]# vim /etc/bashrc

这样就可以永久保存,退出后重新连接依然有效!!

相关推荐

  1. linux如何alias自定义命令永久生效?

    2024-06-16 18:52:01       41 阅读
  2. 使用alias定义命令别名

    2024-06-16 18:52:01       40 阅读
  3. react脚手架创建项目,配置别名alias

    2024-06-16 18:52:01       40 阅读
  4. 使用Linux别名简化命令输入

    2024-06-16 18:52:01       39 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-16 18:52:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-16 18:52:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-06-16 18:52:01       87 阅读
  4. Python语言-面向对象

    2024-06-16 18:52:01       96 阅读

热门阅读

  1. 编程中的delete用法:深入探索与实战应用

    2024-06-16 18:52:01       34 阅读
  2. mybatis LambdaQueryWrapper之复杂与或非sql逻辑编写

    2024-06-16 18:52:01       31 阅读
  3. 怀庄之醉和豫腾贸易的关系

    2024-06-16 18:52:01       29 阅读
  4. 杂笔: 物体的三维识别与6D位姿估计

    2024-06-16 18:52:01       27 阅读
  5. 9、Spring之Bean生命周期~依赖注入(总)

    2024-06-16 18:52:01       32 阅读