Linux boot environment variable path setting __linux

Source: Internet
Author: User
This case implementation adds ~/mypath/bin to the PATH environment variable.
Ubuntu Exclusive way to add environment variablesEdit the/etc/ld.so.conf file, and if the following statement does not exist, join:
Include/etc/ld.so.conf.d/*.conf
Then create a new file below/etc/ld.so.conf.d that ends with. conf.
Write the path you want to set in the new. conf file, for example:

~/mypath/bin


Universal Linux, according to the scope of the role of environment variables are divided into the following two categories: Effective for single users, all users (or systems) effective
The Current user effective environment variable settings
1. bashrc files under the user directory
In the user's home directory, there is a. bashrc file that edits the file:
$gedit ~/.BASHRC
At the end, add the shell statement that requires the variable to be set, for example:
Export Path=~/mypath/bin: $PATH
After the file is saved, it can be immediately taken into effect in the newly opened terminal window.

Variables added in this way can only be used by the current user.

Effective method:

SOURCE ~/.BASHRC


second, the system effective environment variable setting
1, the system directory under the profile file
In the system's etc directory, there is a profile file, edit the file:
$gedit/etc/profile
At the end, add the shell statement that requires the variable to be set, for example:
Export Path=~/mypath/bin: $PATH
After the file is edited and saved, reboot the system and the variable takes effect.

The variables added in this way are valid for all users.

Effective method:

Source/etc/profile

2, the System directory of environment files
In the system's etc directory, there is a environment file to edit the file:
$gedit/etc/environment
Locate the following PATH variable:
Path= "<......>"
Modify the path variable in which you can add your own path, for example:
Path= "~/mypath/bin:<......>"

Each path is separated by a colon. The file is also reset effective and affects all users.

Effective method:

Source/etc/environment


3,/ETC/BASHRC:

Add Method:

Export Path=~/mypath/bin: $PATH

Each user running the Bash shell executes this file. When the bash shell is opened, the file is read and it takes effect.

So the method is to use all the users running the bash shell.

Effective method:

A, restart terminal

B, SOURCE/ETC/BASHRC


make new Add environment variable effective method

1, reboot the system;

2, source corresponding documents;

3, restart the client;




Reference:

1, Ubuntu set the environment variable and path method, http://blog.chinaunix.net/uid-26285146-id-3138789.html

2, http://jingyan.baidu.com/article/db55b609a3f6274ba30a2fb8.html

3,/etc/profile,/ETC/BASHRC, ~/.bash_profile, ~/.BASHRC, http://blog.chinaunix.net/uid-26435987-id-3400127.html

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.