[Linux] setting environment variables in Linux

Source: Internet
Author: User

Set environment variables in Ubuntu


There are three methods to set environment variables in Ubuntu: one for the current terminal, the other for the current user, and the other for all users.:



I. Used on the current terminal:

Enter:Export Path = $ path: <path you want to add>

However, the above method only applies to the current terminal. Once the current terminal is closed or in another terminal, it is invalid.



Ii. Used for the current user:

There is a. bashrc hidden file in the user's main directory. You can add the path settings in this file as follows:

VI ~ /. Bashrc

Join:

Export Path = <path you want to add>: $ path

If you want to add multiple paths, as long:

Export Path = <the path you want to add 1 >:< the path you want to add 2 >:......: $ path

Each path must be separated by a colon.

In this way, each login will take effect.



3. for all users:

Sudo VI/etc/profile

Join:
Export Path = <path you want to add>: $ path

You can.


Terminal input:Echo $ PATH allows you to view environment variables



Note: After the environment variable is modified, except for the first method, the second method takes effect immediately ~ /. Bashrc or log out and log on again!




Done!

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.