Three ways to set environment variables under Linux

Source: Internet
Author: User

1, under the Windows system, many software installations need to configure environment variables, such as installing the JDK, if you do not configure environment variables, run the JAVAC command in a directory other than the software installation, you will report a similar error that the file cannot be found.

2. What are environment variables? To put it simply, it is to specify a directory, when running the software, the relevant program will follow the directory to find the relevant files. The most practical function of setting variables is that you don't have to copy some DLL files into the system directory, and path is a system variable that is a series of paths for the system to search for DLL files.

Under the Linux system, if you download and install the application, it is very likely that the "command not found" prompt will appear when you type its name. If you go to the installation directory folder every time, it is too cumbersome to find an executable file to work with. This involves setting the environment variable path, which is also a part of customizing the environment variable under Linux

three ways to set environment variables under Linux :

If you want to add a path to $path, you can do this as follows:

1, console settings, not in favor of this way, because he only to the current shell function, change a shell setting is invalid:

$PATH = "$PATH":/new_path (Close shell path reverts to the original path)

2, Modify the/etc/profile file, if your computer only as a development use of the push to use this method, because all the user's shell has the right to use this environment variable, may bring security issues to the system. This is for all the users, all the shells

Add at the bottom of/etc/profile: Export path= "$PATH:/new_path"

3, Modify the BASHRC file, this method is more secure, it can use these environment variable permissions to control the user level, here is for a specific user, if you need to give a user permissions to use these environment variables, you only need to modify their personal user home directory. The BASHRC file is available.

Add the following:

Export path= "$PATH:/new_path"


This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1791027

Three ways to set environment variables under Linux

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.