In linux, how does one make the command alias take effect after restart?

Source: Internet
Author: User
System environment: RHEL5.31.alias can be used to set the alias of a command, for example, [root @ localhost ~] # Alias // view the default set alias aliascp & amp; #39; cp-I & amp; #39; aliasl. & amp; #39; ls-d. * -- colortty & amp; #39; aliasll & amp; #39; l...

System environment: RHEL5.3
1. alias can set command alias
For example:
[Root @ localhost ~] # Alias // view the default system alias
 
Alias cp = 'CP-I'
Alias l. = 'ls-d. * -- color = tty'
Alias ll = 'ls-l -- color = tty'
Alias ls = 'ls -- color = tty'
[Root @ localhost ~] # Alias pw = passwd // Set the passwd command
[Root @ localhost ~] # Pw
Changing password for user root.
New UNIX password:
[Root @ localhost ~] # Unalias pw = passwd // undo the alias you just set
However, after this setting, the alias becomes invalid after the system restarts. how can I make the alias take effect after it is restarted?
Method 1:
There is a. bashrc in the user's home directory. use vim to open this file and add the alias you want to set. for example
Alias rm = 'rm-I'
Alias cp = 'CP-I'
Alias mv = 'MV-I'
Method 2:
Method 1 is feasible, but the alias just set does not work when other users log on to the linux host. so we will introduce method 2 here:
Use vim to open the/etc/bashrc directory and add the alias you want.
Alias rm = 'rm-I 'alias cp = 'CP-I'
Alias mv = 'MV-I'

At this time, even if the computer is restarted, or other users can use the alias you just set for logon!

 
 
 
Author: "New network subnet"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.