Settings for Linux environment variables

Source: Internet
Author: User

Environment variables in Linux are divided into system environment variables and user environment variables (as in window), System environment variables are valid for all system users, user environment variables are only valid for current users, we use Ubuntu as an example to illustrate

User Environment variables

User environment variables are typically stored in the following file

  1. ~/.profile
  2. ~/.bash_profile or ~/.bash_login
  3. ~/.profile

System Environment variables

User environment variables are typically stored in the following file

  1. /etc/environment
  2. /etc/profile
  3. /etc/bash.bashrc

modifying environment variables

If you want to add a path to $path, you can do the following (modify/etc/profile)

sudo vim/etc/profile

Add your own path to the end of the file

Export  path= "$PATH:/my_new_path"

You can add the specified number of paths yourself, separated by colons. When the environment variable is changed, it takes effect the next time the user logs on, and if you want to take effect immediately, you can execute the following statement:

Source/etc/profile

Other files are modified in a similar manner, and it is important to note that/etc/environment does not need to use export to set environment variables that other profile files require.

For more detailed instructions on environment variables, please refer to Https://help.ubuntu.com/community/EnvironmentVariables

Settings for Linux environment variables

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.