1. Environment Variables

An environment variable is a dynamic-named value containing information about your login session, set configuration options, and customize the shell environment in Linux-based operating systems. In simple terms, an environment variable is used to define a location for storing a value, you can also refer to its symbolic name. These values are stored within the system and are used by command-line applications. The stored value can be deleted, displayed, edited, and re-saved.

2.1 Use printenv to print all environment variables.

2.2 You can set a temporary environment variable by:

MY_NAME=TAIYI

Then call this variable as $MY_NAME, for example:

echo $MY_NAME

Notice that the above environment variables are available only for the current session. If you open a new shell, or if you log out, all variables will be lost.

Please verify this.

2.3 Setting a Persistent Environment Variable

One way to set a persistent environment variable is to use the user-based configuration file .bash_profile in your home directory. With Bash, you can declare the variables in the following format:

export MY_NAME=TAIYI

Please add the above line to your .bash_profile, then save .bash_profile.

To update current environment variables, run:

source .bash_profile

Now, we have made $MY_NAME a persistent environment variable, and it will be loaded every time you log in.