In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to create permanent aliases in Linux", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to create permanent aliases in Linux" article.
The main purpose of the Linux alias command is to set aliases for instructions and to simplify some longer commands. When using alias, you must include the original command in single quotation marks to prevent special characters from causing errors.
Lists aliases currently defined in Linux
Simply execute the alias command to see a list of defined aliases in the configuration file.
[linuxidc@localhost www.linuxidc.com] $aliasalias egrep='egrep-- color=auto'alias fgrep='fgrep-- color=auto'alias grep='grep-- color=auto'alias l.='ls-d. *-- color=auto'alias ll='ls-l-- color=auto'alias ls='ls-- color=auto'alias running_services='systemctl list-units-- type=service-- state=running'alias vi='vim'alias which='alias | / usr/bin/which-- tty-only-- read-alias-- show-dot-- show -tilde'Linux Alias command brief introduction Linux Alias command brief introduction
Here, you can see the default aliases defined for your users in CentOS 7.6.
As you can see, execute.
$ll
It is equivalent to running:
Ls-l-color=auto
You can use a single character to create an alias that will be equivalent to the command of your choice.
How to create an alias in Linux
Creating aliases is relatively easy and fast. You can create two types of aliases-temporary aliases and permanent aliases. We will review these two types.
Create a temporary alias
All you need to do is type the word alias, and then use the name you want to use to execute the command, followed by the "=" symbol and reference the command you want to alias.
The syntax is as follows:
$alias abbreviation = 'here is your custom command'
This is a practical example:
$alias idc='cd / home/www/share'
You can then use the "idc" shortcut to go to the / home/www/share directory. The problem with this alias is that it only applies to your current terminal session.
If you open a new terminal session, the alias will no longer be available. If you want to save aliases across sessions, you need a permanent alias.
Create a permanent alias
To keep aliases between sessions, you can save them in the user's shell configuration file. This can be:
Bash-~ / .bashrcZSH-~ / .zshrcFish-~ / .config/fish/config.fish
The syntax you should use is almost the same as creating a temporary alias. The only difference is that this time you save it in a file. For example, in bash, you can open the .bashrc file using your favorite editor, as follows:
$vim ~ / .bashrc
Find the location in the file where you want to keep the alias. For example, you can add them to the end of the file. For organizational purposes, you can leave a comment before the alias, as follows:
# my custom alias alias home= "ssh-I ~ / .ssh/mykep.pem linuxic@192.168.1.199"
Save the file. The file will be automatically loaded in your next session. If you want to use the newly defined alias in the current session, issue the following command:
$source ~ / .bashrc
To delete an alias added through the command line, you can use the unalias command to cancel the alias.
$unalias alias_name$ unalias-a [remove all aliases] above is about "how to create permanent aliases in Linux". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about it, please 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.