Featured

    Featured Posts

ENVIRONMENT VARIABLES

Environment variables are placeholders for data that can change. Each user has environment variables with different values to define his or her working environment. For example, each user typically has its own home directory, so the content of the HOME environment variable is different for each user on the system. A program that needs to know the user’s home directory can refer to theHOME variable to obtain this information.
To see the environment variables on your system, type env:
linux env command
To set an environment variable manually, use an equal-sign assignment operator. If you want your variable to be available to programs you launch from your shell use the export command:
exporting environment variables
In the example above we have assigned the value “example” to the variable VAR1. For brevity, you can comibne these two commands in one: export VAR1=example.
To refer to an environment variable, you must put special the dollar sign ($) in front of the variable name:
linux referring environment variables
In the example above we have used the echo command to display the content of the variable VAR1.
Setting an environment variable as just described sets it permanently only for the current shell. For example, if we open another terminal window, the variable VAR1 will not be set:
linux environment variable in the new shell
To make environment variables permanent you need to set them in a global or local bash startup script.
NOTE – environment variables can be deleted by using the unset command, which takes the name of an environment variable (without the leading $ symbol) as an option. In our case,unset VAR1 deletes the VAR1 environment variable.
author

Author Name

Author Description!

Get Free Email Updates to your Inbox!

Post a Comment

www.ccna.ma

yu
Powered by Blogger.

Translate

Copyright © Learn Linux Th3pro.xyz | Blogger Templates | Designed By Code TAOUSSI