"Go" Ubuntu Setup path----good

Source: Internet
Author: User
Tags readable

Original URL: http://no001.blog.51cto.com/1142339/554927

Tried many times, many invalid.

The final setting is only valid under/etc/enviroment.

But let's have some unresolved questions.

I use sudo su

Enter the root user right, set to complete.

Re-use Sudo-s to enter the root user right, you will not see the path set,

It's strange to look at the root problem.

Related information:

、、、、、、、、、、、、、、、、、、、、、、、、、、

1. Ubuntu Proprietary Way
Edit the/etc/ld.so.conf. Add file if the following statement does not exist:
Include/etc/ld.so.conf.d/*.conf
Then create a new file ending with. conf below the/ETC/LD.SO.CONF.D.
Write the path you want to set in the new. conf file, for example:
~/mypath/bin

2.. bashrc files in the user directory
In the user's home directory, there is a. bashrc file that edits the file:
$gedit ~/.BASHRC
On the last side, add the shell statement that needs to set the variable, for example:
Export Path=~/mypath/bin: $PATH
Once saved, the file can be immediately active in the newly opened terminal window.
Variables added in this way can only be used by the current user.

3, the system directory under the profile file
In the system's etc directory, there is a profile file that edits the file:
$gedit/etc/profile
On the last side, add the shell statement that needs to set the variable, for example:
Export Path=~/mypath/bin: $PATH
After the file edits are saved, the system restarts and the variables take effect.
The variables added in this way are valid for all users.

4. Environment file under the system directory
In the system's etc directory, there is a environment file that edits the file:
$gedit/etc/environment
Locate the following PATH variable:
Path= "<......>"
Modify the path variable to include your own path, for example:
Path= "~/mypath/bin:<......>"
Each path is separated by a colon. The file is also restarted to take effect, affecting all users.

=========================================================

There are two ways to set the environment variable PATH in the Ubuntu system. The first applies to setting the path for a single user, and the second is to set the path globally.
The first method:
There is a. bashrc file under the user's home directory, and you can include the PATH in this file with the following settings:
Export path= "$PATH:/your path1/:/your path2/..."
Note: Separate each path with a ":".
Log out and restart X on it.
The second method:
Increased in/etc/profile.
Export path= $PATH:/home/zhengb66/bin


environment variables are closely related to the shell, and the user logs on to the system and launches a shell. It's usually bash for Linux, but it can be reset or switched to another Shell. For UNIX, it could be cshelll. Environment variables are set by shell commands, and set environment variables can be used by all current users running programs. For bash, the shell program can use variable names to access the appropriate environment variables, and export to set environment variables. This is illustrated by a few examples below.

1) Etc/profile:
This file sets the environment information for each user of the system, and the file is executed when the user logs on for the first time.
and collect the shell settings from the configuration file of the/ETC/PROFILE.D directory.
Note: Here we set the global variables that are available to all users.

2)/ETC/BASHRC:Execute this file for each user running the bash shell. When the bash shell is opened, the file is read.

3) ~/.bash_profile:Each user can use this file to enter shell information that is specific to their own use.when the user logs in, the file is only executed once!By default, he sets some environment variables to execute the user's. bashrc file.
Note: ~ Under Linux is the variable representing the home.
In addition, under different Linux operating systems, this file may be different and may be
~/.bash_profile; ~/.bash_login or ~/.profile one or more of them, if there are several, then the order of execution is: ~/.bash_profile, ~/.bash_login, ~/. Profile For example, I use Ubuntu, my User folder, the default is only the ~/.profile file.

4) ~/.BASHRC:This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell.
(Note: This file is. Beginning, so it is hidden in the folder)
So how do we add our own defined environment variables?
Open the file with Notepad, and then write it in the last:
Xiaokang=kangkang
And then save it so that each time we open a new terminal, we have this variable in effect. Remember, if you have opened a terminal, and then you modify the file, then this terminal will not be effective.
In general, the user is best to make changes here, but sometimes it will overwrite the parent variables, such as path is root set, but if you write in this file path=xx, then all of the future path is XX, so we should write in this file:
Path= $PATH: XX
This adds the original and your own. and pay attention to the Linux system using: segmentation, not windo;
3 and 4 are all in the user directory, their only difference is:. Bash_profile can only be started once when logging in. This 3 file does not seem to be in my Ubuntu.

5) ~/.bash_logout:Executes the file each time it exits the system (exiting the bash shell).
In addition, the variables set in/etc/profile (global) can be applied to any user, while the variables set in ~/.BASHRC, etc. (local) only inherit variables from/etc/profile, they are "parent-child \" relationships.

~/.bash_profile is interactive, login way into bash run
~/.BASHRC is an interactive non-login way into bash run
Usually the two settings are roughly the same, so the former usually calls the latter.

OK, let's summarize how they do it:
When you log in and the shell is bash, bash first executes the command in the/etc/profile file (if the file exists), and then it looks for the ~/.bash_profile,~/.bash_login or ~/.profile file sequentially, and executes the command found in the first readable file. When login bash exits, it executes the commands in the ~/.bash_logout file.
When you start an interactive bash, it executes the commands in the ~/.BASHRC file (if the file exists and is readable). When you start non-interactively to run a shell script, bash looks for the BASH_ENV environment variable to determine the name of the execution file.

This article is from the "unfocused of Life" blog, please be sure to keep this source http://no001.blog.51cto.com/1142339/554927

"Go" Ubuntu Setup path----good

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.