Set environment variables in Linux and environment variables in linux

Source: Internet
Author: User

Set environment variables in Linux and environment variables in linux

There are two types of Shell sessions: login shell session and non-login shell session. The login shell session prompts the user to enter the user name and password, such as the virtual console session. The terminal session started in the GUI is a typical non-login shell session.

After you log on to the system, the bash program starts and reads a series of startup files. Login shell reads one or more startup files, as shown in the following table:

File Description
/Etc/profile Global configuration scripts for all users
~ /. Bash_profile User's personal Startup File. The global configuration script can be expanded or rewritten.
~ /. Bash_login If ~ /. Bash_profile missing, bash tries to read this script
~ /. Profile If ~ /. Bash_profile and ~ /. Bash_login is missing, bash tries to read this file. In Debian-based Linux (such as Ubuntu), this is the default value.

 

 

 

 

 

The Startup File Read by the non-login shell is as follows:

File Description
/Etc/bash. bashrc Global configuration scripts for all users
~ /. Bashrc User's personal Startup File. Extensible or program global configuration script

 

 

 

In addition to reading the above Startup File, the non-login shell inherits the environment of the parent process, which is usually a login shell.


You can customize the environment variables by modifying the Startup File, for example, in ~ /. Bashrc Configuration:

export JAVA_HOME=/usr/lib/jvm/java-7-sunexport PATH=$PATH:${JAVA_HOME}/bin

 

It is read only when the shell session is started ~ /. Bashrc, SO ~ /. The modification made by bashrc takes effect only when the shell terminal session is closed and restarted. You can also use the source command to re-read bash ~ /. Bashrc file:

source ~/.bashrc

 

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.