Ubuntu Linux Set Environment variables

Source: Internet
Author: User

Adding environment variables

1. Add Temporary variables

Input in Terminal:

Path= "$PATH: Yourpath": Yourpath is the environment variable to be added (that is, the absolute path to add the directory, for example:/home/myprogram)

The pro-Test takes effect without any other action, but fails after restarting the terminal.

2. Add a permanent variable

Method 1: (Add system environment variables)

Input in terminal

sudo gedit/etc/environment (or Open with VI: sudo vi/etc/environment)

In the Path= "..." Line finally, separated by a colon and your previous variables, and add your environment variable, after adding the form such as: Path= "...:/home/myprogram" (ellipsis for Add before environment variable)

To make it effective immediately:

        Source/etc/environment

Method 2: (Add bash environment variable, tcsh still do not know how to do, should be similar)

Open command/.BASHRC (Bash settings file):

sudo gedit/.BASHRC

Add the following command on the first or last line (as long as you do not separate one of the other blocks, obviously the first and last lines are more insured):
Path= $PATH:/home/myprogram
This requires restarting the terminal to make it effective

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.