I assume that you are coming from windows. So I will compare them (I am also new to Linux). I found the user's response to my comment to be helpful in sorting out.
On Windows, a variable can be constant or not. The term "environment variable" includes the variable set on the cmd command line with the SET command, and also when the variable is set in the Windows GUI, therefore it is installed in the registry and becomes visible in new cmd windows. for example, the documentation for the sed command in the windows https://technet.microsoft.com/en-us/library/bb490998.aspx "Displays, sets, or deletes environment variables. Used without parameters, sets the current environment settings." On Linux, a set does not display environment variables; it displays shell variables that it does not call / does not refer to as environment variables. In addition, Linux does not use the set to set variables (in addition to the positional parameters and shell parameters, which I explain as a note at the end), only to display them, and even then only to display shell variables. Windows uses a set for configuration and display, for example. set a = 5, linux - no.
On Linux, I think you can make a script that sets variables at boot, for example. /etc/profile or /etc/.bashrc , but otherwise they are not constant. They are stored in RAM.
On Linux, there is a distinction between shell variables and environment variables. On Linux, shell variables are found only in the current shell, and environment variables are in this shell and all child shells.
You can view shell variables using the set command (although note that, unlike windows, variables are not set on Linux using the set command).
set -o posix; set set -o posix; set (doing this set -o posix first, helps not to display too many unnecessary things). Therefore, set displays shell variables.
You can view environment variables using the env command
shell variables are set, for example, just a=5
environment variables are set with export; export also sets a shell variable
Here you see the zzz shell variable with zzz = 5, and its view is displayed when set run, but does not appear as an environment variable.
Here we see yyy set with export, so this is an environment variable. And you will see that this is displayed both in shell variables and in environment variables
$ zzz=5 $ set | grep zzz zzz=5 $ env | grep zzz $ export yyy=5 $ set | grep yyy yyy=5 $ env | grep yyy yyy=5 $
other useful topics
https://unix.stackexchange.com/questions/176001/how-can-i-list-all-shell-variables
https://askubuntu.com/questions/26318/environment-variable-vs-shell-variable-whats-the-difference
Note. One point that clarifies a little and corrects to some extent what I wrote is that in linux bash, “set” can be used to set “positional parameters” and “shell parameters / attributes”, and technically both of them are variables, although the manual pages may not describe them as such. But still, as already mentioned, set will not set shell variables or environment variables). If you execute set asdf , then it sets $ 1 to asdf, and if you do echo $1 , you see asdf. If you do set a=5 , it will not set the variable a to 5. It will set the positional parameter $ 1 to the string "a = 5". Therefore, if you have ever seen the set a = 5 in linux, this is probably a mistake if someone really did not want this line a = 5, in $ 1. Another thing that the linux suite can set is shell options / attributes. If you installed - you see a list of them. And you can do, for example, set -o verbose , off to enable verbose (btw is disabled by default, but that doesn't make any difference to this). Or you can do set +o verbose to disable verbose text. Windows does not have such use for the set command.