Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use alias command in Linux system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how to use alias commands in the Linux system. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

The use of 1.alias

The alias command is used to set the alias of the instruction. We can use this command to simplify some longer commands.

Use the alias short command = 'original command option'

Alias 138ssh = 'ssh-I ~ / .ssh/138.pem ec2-user@192.168.21.138'

Then you can directly use 138ssh to replace the original ssh-I ~ /. Ssh/138.pem ec2-user@192.168.21.138

View all current alias alias-p

Delete an alias unalias command

Then I happily used the short command so that I no longer had to remember the ip address of the server.

Persistence of 2.alias

The next day, when I was at work, I happily typed out my short order and found that

Run quickly to ask the operation and maintenance brother, and then tell me that alias needs to be reset every time it restarts.

Then how can we play?

Luckily, the operation and maintenance brother taught me another trick.

Add the alias command to the / etc/.bashrc or ~ / .bashrc file so that you don't have to reset every restart

/ etc/.bashrc is valid for all users, and ~ / .bashrc is valid for current users

Ps: my system is deep linux modified / etc/bash.bashrc

Finally, execute the source / etc/bash.bashrc command and the short command set by alias can be used again.

Note: source Filname reads and executes commands in FileName in the current bash environment

The above is how the alias command shared by the editor is used in the Linux system. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report