Three ways to configure the Linux environment variables

Brief introduction

Linux system environment variables, it is a popular shortcut to a complex character acronyms or an address, such as the commonly used PATH, HOME variable, respectively, represent the / bin: / usr / bin: / usr / local / bin : ... and / home / [username] /. Mainly to more user-friendly, after all remember a word much easier than remembering the strings of characters.
In the Linux system, environment variable settings file has a plurality of, e.g. /etc/profile,~/.bashrc and / etc / environment, etc., may be provided directly by export, wherein the / etc / environment generally not used, the following summarizes the main with / etc / Profile , ~ / .bashrc file and export three ways to set the environment variables.

Set three common ways

/etc/profile

/ etc / profile set in the system environment variables, environment variables take effect for all users, it is to read and set the landing system, once again landed modify environment variables permanent.

~/.bashrc

~ / .bashrc set the current user's environment variables need to re-open the terminal to take effect in the current user.

export

Indeed / etc / Profile , ~ / .bashrc defined environment variables are defined using export, where two or more main difference is in the file, but directly input variables defined in the current export terminal, i.e. a temporary set environment variables, only entry into force of the current terminal.

View the environment variables

Command can be used env or export -p to see the environment variable, or echo $ NAME to view a specific environment variables.

Published 41 original articles · won praise 85 · Views 250,000 +

Guess you like

Origin blog.csdn.net/zhoucoolqi/article/details/96029947