Linux/UNXI system environment variables

Source: Internet
Author: User

Linux/UNXI system environment variables
1. What are environment variables? Simply put, it is to specify a directory. when running the software, the relevant program will find the relevant files according to the directory. The most practical function for setting variables is that you do not need to copy some dll files to the system directory. The path system variable is a series of paths for the system to search for dll files.

2. in Linux, If you download and install an application, the "command not found" prompt may appear when you type its name. It is too cumbersome to find the executable file in the installation directory every time. This involves setting the environment variable path, and the Path setting is also an integral part of customized environment variables in Linux.


Three methods for setting environment variables in Linux:

To add a PATH to $ PATH, perform the following operations:

1. Set in the console. This method is not supported, because it only works for the current shell and is invalid for another shell:
$ PATH = "$ PATH":/NEW_PATH (disabling shell Path will restore to the original path)


2. Modify the/etc/profile file. If your computer is used only for development and usage, this method is used because all users' shells have the right to use this environment variable, security issues may occur to the system. This is for all users, all shells
Add: export PATH = "$ PATH:/NEW_PATH" at the bottom of/etc/profile"


3. Modify the bashrc file. This method is more secure. It can control the permissions to use these environment variables to the user level. This method is for a specific user, if you want to grant a user permission to use these environment variables, you only need to modify. you can use the bashrc file.
Add the following content:

Export PATH = "$ PATH:/NEW_PATH"

Note: Once environment variables are set, they do not take effect immediately. You need to use the source command to re-load the configuration file, for example: source ~ /. Bashrc.

If the system does not have the source command, use the exit command to restart the terminal;

 

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.