Variables
Variables are pieces of storage for data, such as text or numbers. Once set, a variable’s value can be accessed at a later time. Variables have a name which allows accessing a specific variable, even when the variable’s content changes. They are a very common tool in most programming languages.
In most Linux shells, there are two types of variables:
Local variables: There variables are available to the current shell process only. If you create a local variable and then start another program from this shell, the variable is not accesible to that program anymore. Because they are not inherited by sub processes, these variables are called local variables.
Environment variables: These variables are available both in a specific shell session and in sub processes spawned from that shell session. These variables can be used to pass configuration data to commands which are run. Because these programs can access these variables, they are called environment variables.
set: Shows or modify the environment configuration. Without parameters, it visualizes environment viables and with the option -o
a list of options and its states.
export: Create or modify environment variables.
export NOMBRE=Eduardo
unset: Deletes environment variables.
unset NOMBRE
env: Without parameters it shows environment variables. We can use it to execute a command while modifying environment variables.
env PATH=/new/path /bin/bash