Ubuntu Linux system contains two types of environment variables

Source: Internet
Author: User

Ubuntu Linux systems contain two types of environment variables: System environment variables and user environment variables. The system environment variable is valid for all system users, and the user environment variable is only valid for the current user.

modifying user environment variables

User environment variables are typically stored in the following file:

~/.profile

~/.bash_profile or ~./bash_login

~/.bashrc

the above-mentioned documents Ubuntu 10.0 Previous versions are not recommended.

System Environment variables

The system environment variables are generally stored in the following file:

/etc/environment

/etc/profile

/etc/bash.bashrc

/etc/profile and /ETC/BASH.BASHRC are not recommended in the Ubuntu 10.0 version.

If you want to take effect immediately, execute sudo ldconfig

Adding environment variables

If you want to add a path to the $PATH , you can do this as follows (modify /etc/profile):

$ sudo vi/etc/profile

Add in :

Export path= "$PATH:/my_new_path"

You can add a specified number of paths yourself, usually one row per path, press ESC to exit the edit, enter a colon plus wq to save the exit.

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

It is important to note that it is best not to put the current path "./" in path , which may be subject to unexpected attacks.

other files are modified in a similar way, note that/etc/environment does not need to use export to set environment variables, other profiles file required.

For more detailed instructions, refer to here.

Ubuntu Linux system contains two types of environment variables

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.