Setting the default environment variable of Shell in Linux (BASH)

Source: Internet
Author: User

In Linux, shell is a commonly used tool. In Red Hat Linux, we usually use B shell or bash. In Shell, we always want to set some environment variables or other initialization operations when opening this shell. But how can we do this? Although we can use the set or Export Statement to set the environment variable, it is very painful to re-open another shell and re-export it. On Windows, we can set the PATH environment variable in the attributes of my computer. in Linux, it seems that this option is not found. What should we do.

In fact, it is in the directory of each user. For example, if your user name is test, there is a. bashrc hidden file under the/home/test directory. You can open this file through VI. Then write some statements in the file. These statements are automatically run during shell initialization, and your environment variables are automatically set. For example, in the current. bashrc file, add the following statement:

Sbin =/ Sbin
Export Path = $ Path : $ Sbin

Then exit VI and enter source. after the bashrc command is imported, you will find that the ifconfig command under/sbin can be run without/sbin. If you do not believe it, You can directly enter the command ifconfig to see it. Re-open a shell and find that the ifconfig command can be run directly.

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.