Where is environment variable in linux
Every time you start a shell session in Linux, the system goes through configuration files and sets up the environment accordingly. Environment variables play a significant role in this process. In this tutorial, you will learn how to set, view, and unset environment variables in Linux. Environment variables are variables that contain values necessary to set up a shell environment. Structurally, environment and shell variables are the same — both are a key-value pair, separated by an equal sign.
Note: The convention is to use all caps for writing variable names, in order to distinguish them among other configuration options. Use the printenv command to view all environment variables.
Since there are many variables on the list, use the less command to control the view:. The output will show the first page of the list and then allow you to go further by pressing Space to see the next page or Enter to display the next line:.
Alternatively, display the value of a variable by using the echo command. The syntax is:. To find all the variables containing a certain character string, use the grep command :. Another command you can use to check environment variables is set.
Your PATH variable is vital to your terminal emulator, for instance, but a lot less significant to, say, Java which has its own paths, which point to important Java libraries. However, the USER variable is used by several systems as a way to identify who is requesting a service. Or you might choose to add an environment variable to suit your preferences. If you decide you want to keep some applications in a bin folder located in your home directory, then you must add that directory to your PATH so your operating system knows to look there for applications to run when you issue a command.
You can add a location to your path the way you create throw-away variables. It works, but only as long as the shell you used to modify your system path remains open. For instance, open a Bash shell and modify your system path:. For that, you must configure your variables to load any time a shell is launched.
The syntax for setting a variable by configuration file is the same as setting a variable in your shell:. You can create and manipulate environment variables at will, and some applications do just that. So the question is: How do you find out which environment variables are meaningful? For instance, to find out what options are available to you for your general Bash environment, you can read the Bash documentation. While the Bash man page mentions many important variables, the GNU info page for Bash features two exhaustive lists of useful Bourne Shell and Bash environment variables, and how each is used.
Environment variables can be created, edited, saved, and deleted and give information about the system behavior. Click here if the video is not accessible. This value is read by an application such that a Chinese user is shown a Mandarin interface while an American user is shown an English interface.
This variable contains a colon : -separated list of directories in which your system looks for executable files.
If the command is found, it executes. Variables are- Case Sensitive. Make sure that you type the variable name in the right letter case otherwise you may not get the desired results.
Previous export command in Linux with Examples. Next pwd command in Linux with Examples. Recommended Articles. Article Contributed By :. Archana choudhary. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide.
0コメント