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 implement alias management by using alias in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

How to use alias in Linux to achieve alias management, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Linux alias Management alias

In the daily Linux usage management, in order to facilitate the use of habits and simplify some longer and more complex commands, we will set some simple and commonly used aliases, and use the alias command under Linux to view and set aliases.

View the current shell environment and aliases that are in effect

I use CentOS 7 minimum installation system, and many aliases have taken effect by default in base shell environment, as follows:

# check the current shell type [calmsnow@localhost ~] $echo $SHELL/bin/bash# to query the alias [calmsnow@localhost ~] $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 which='alias | / usr/bin/which-- tty- Only-read-alias-show-dot-show-tilde'

We usually use the ls and grep commands to get a color in the final output, as well as the ll command we are used to, all because this alias is set by default in base shell

Custom alias

Take effect temporarily

Aliases executed with the alias command will only take effect on the current shell terminal, and the new opening of the shell terminal or switching the user environment will be invalid, as shown below:

[calmsnow@localhost ~] $alias ps='ps-ef | grep'

Take effect permanently

If you want to permanently take effect on the current user, you can vi ~ / .alias, add aliases at the end of the file; if you want aliases to take effect globally for all users, you can sudo vi / etc/bashrc, and add aliases at the end of the file in the following format (I listed my common alias settings):

Alias vi='vim'alias ps='ps-ef | some aliases of grep'# should not overlap with system commands. Is it helpful for you to use aliases to manage nginxalias nginxreload='/data/nginx/sbin/nginx-s reload'alias nginxstart='/data/nginx/sbin/nginx-c / data/nginx/conf/nginx.conf' after reading the above? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Internet Technology

Wechat

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

12
Report