Ubuntu environment configuration records: (5) several methods and differences for setting environment variables, and java environment variable settings

Source: Internet
Author: User

Ubuntu environment configuration records: (5) several methods and differences for setting environment variables, and java environment variable settings
Single User:
. Bashrc: execute this file for every user running bash shell. When bash shell is opened, the file is read.
Open. bashrc in the user's main directory and add
Export PATH = "$ PATH: export PATH =" $ PATH:/home/***/android-sdk-linux_86/platform-tools /"
Restart or log out.


Global settings:
/Etc/profile is the environment variable of all users
Add/etc/profile
Export PATH = "$ PATH:/home/***/android-sdk-linux_86/platform-tools /"


System settings:
/Etc/enviroment is the system environment variable
Export PATH = "$ PATH:/home/***/android-sdk-linux_86/platform-tools /"


Therefore, when you configure a path to profile and enviroment, you cannot use the default command to open a new terminal.
For example, after setting export PATH = ***/android-sdk-linux_86/platform-tools in profile and enviroment,
If you do not use the source command in the newly opened terminal, you still cannot use the adb command. However, if you have set the command in. bashrc, the newly opened terminal can use adb directly.


If the same variable has different values in the user environment (/etc/profile) and system environment (/etc/environment), the user environment should prevail.
How to Set environment variables ?? Ubuntu Daniel

The above section teaches you how to set the TAUP_HOME environment variable.
If the shell you are using is csh or tcsh, use the setenv command;
If it is bash, use the export command.
In the example given above, you install the TauP program in/usr/local/share, that is, the installation directory of TauP is/usr/local/share/TauP-1.2.0. Input
Setenv TAUP_HOME/usr/local/share/TauP-1.2.0
Or
Export TAUP_HOME =/usr/local/share/TauP-1.2.0
You can set the environment variable TAUP_HOME to/usr/local/share/TauP-1.2.0.

What are the differences between the methods for changing environment variables in linux (ubuntu?

You can try it one by one.
1./etc/profile: The first file used by the operating system to customize the user environment during login. This file sets environment information for each user in the system. When the user logs on for the first time, the file is executed.
2./etc/environment: the second file used by the operating system during logon. Before the System reads your own profile, it sets the environment variable of the environment File.
3 ,~ /. Bash_profile: The third file used for logon is. bash_profile file. Each user can use this file to input shell information dedicated to their own use. When a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file. /Etc/bash. bashrc: execute this file for every user running bash shell. When bash shell is opened, the file is read.
4 ,~ /. Bashrc: This file contains bash information dedicated to your bash shell. This file is read when you log on and every time you open a new shell.
Priorities of several files: 1> 2> 3
In linux, if it is a bash environment, the order in which the user reads the set files during logon is/etc/profile --> ~ /. Bash_profile --> ~ /. Bashrc -->/etc/bash. bashrc. Note that ~ /. Bash_profile, if no ~ /. Bash_profile, the default read ~ /. Bash_login. If no ~ /. Bash_login to read ~ /. Profile.
Based on the release version, there are two basic system-level configuration files:/etc/bash. bashrc and/etc/profile. These configuration files contain two different variables: shell variables and environment variables. The former is only fixed in a specific shell (such as bash), and the latter is fixed in different shells. Shell variables are local, while environment variables are global.
Note: avoid modifying the environment variable configuration file of the root user as much as possible, because this may cause potential risks. It is recommended that you do not put the current PATH "./" in the PATH, which may cause unexpected attacks.
Usage:
Apply the set environment variables to all users:/etc/bashrc;/etc/profile
Modify global environment variables in/etc/profile
Modify the environment variable of a user in/home/user name/. bash_profile

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.