The environment variable setting technique under Linux, do not need to/etc/profile but create a new shell file in the/ETC/PROFILE.D directory to set

Source: Internet
Author: User

Difference:

1, two files are set environment variable file,/etc/profile is a permanent environment variable, is a global variable,/etc/profile.d/set all users to take effect, is also a permanent variable, is a global variable.

2,/etc/profile.d/than/etc/profile good maintenance, do not want to what variables directly delete/etc/profile.d/under the corresponding shell script can, not like/etc/profile need to change this file.

3. It is important to note that/etc/profile and/ETC/PROFILE.D are also login-level variables that are triggered when the user logs back into the shell. So the effect is consistent.

4, usually set the login level of variables, re-login shell can, or source/etc/profile.

Originally:

Setting environment variables is usually written in/etc/profile, now it seems really low, if hundreds of applications, then find and modify to get is a different thing! So the problem is that the upgrade is done by creating a shell file in the/etc/profile.d/directory to apply the command, and then removing the required variables directly from the shell file.

Right now:

The same way, just create a new shell in the/etc/profile.d/directory, such as new Java:

vi/etc/profile.d/java.sh

Export Java_home=/data/service/java

Principle:

Whether in Linux or Mac, can be implemented in this way, analysis/etc/profile This file you will find a shell, this is the key:

if  then   for  in/ETC/PROFILE.D/*. sh; do    if [-R $i]; then      . $i Fi-Done  unset ifi

Summarize:

Do not use the same low way before, change the plan, so operation is the King!!!

The environment variable setting technique under Linux, do not need to/etc/profile but create a new shell file in the/ETC/PROFILE.D directory to set

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.