Linux Bash shell Local Variables

Local or shell variables exist only in the current shell session. Other commands or applications outside of the current shell session cannot be affected by or have any interaction with these variables. All of these variables are lost, from the moment a user closes a terminal window or shell. The convention is that the names of these variables are lowercase. The local variables are often associated with user-based tasks.

A shell variable is specific to the shell itself and will not be inherited by any child process. For example, let's create a shell variable and run an application after the creation of the variable:

testuser1@testuser1-host:~$ example_var=sample_text
testuser1@testuser1-host:~$ firefox

The variable example_var will not be available in the environment of firefox, which is the child process. In other words, the firefox process will not have access to example_var.

You can use the echo command to see the content of your variables. Let's see the content of the variable that we've created, example_var:

testuser1@testuser1-host:~$ echo $example_var 
sample_text

Other articles:

Linux Bash shell variables

Linux Bash shell variables - Environment Variables

How to create Linux Bash shell variables

How to remove Linux Bash shell variables

How to make Linux Bash shell variables persistent

Environment variables in python - part 1

Environment variables in python - part 2

Environment variables in python - part 3