Change system environment settings to allow the alias to take effect forever

Source: Internet
Author: User
Tags aliases

The alias (Chinese called "Alias") allows you to redefine the Shell command in Linux with a shorter name, simplifying the command line input. If you often deal with the CLI, using the alias will not only save time but also improve efficiency, and it is a good thing to kill the birds. Basic usage: The basic use of alias is: alias new command = ' original command-option/parameter '. For example, alias l= ' Ls-lsh ' will redefine the LS command, and now you can just type L to list the directory. Learn aliases: direct input to the alias command lists all the command aliases that are already defined in the current system. Remove alias: To remove an alias, you can use the Unalias command, such as Unalias L.

The above is seen on the Internet, this method is only temporary, if the restart is invalidated, if we want to permanently effective an order how to do it?

Open. BASHRC (should be an Ubuntu release, and other distributions may be modified. Bash_profile) you can see

......

# some more LS aliases

Alias Ll= ' Ls-alf '
Alias La= ' Ls-a '
Alias l= ' LS-CF '

......

Method 1: Add alias xx= ' xxxxx ' directly to our environment variable file

Method 2: There is a word in BASHRC.

# you could want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.

That means you can create a new file to store your own alias information.

Cases

$ cd

$ vi. bash_aliases

Enter the command you want to set in the file alias rm= ' Rm-i ' and save the launch

$ source. BASHRC #让我们的环境生效

Method......

Summary:

1. Most of the time we only pay attention to solve the problem itself, but often ignore other things, in the process of solving the problem is also a learning opportunity, especially do not forget to look at the software source and so on comments. Suddenly found this is very important, because I read the annotation, I found this method, and my original purpose is to make changes to my own environment variables, in solving the problem of environmental variables at the same time I have to solve the problem of the alias, I have to remember ...

2. When looking for solutions on the Internet, it is often found that other people have files that are not native, for example. BASHRC and. Bash_profile may be on different distributions, this time you can change the search method, or try it yourself ...

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.