Using Variables

Learn how to use shell variables.

We'll cover the following...

Printing variables

If we want to print one of the environment variables to the screen, we use the printenv command, followed by the variable name:

$ printenv HOME

Use the terminal below to practice these commands.

Terminal 1
Terminal
Loading...

This is good for checking the value, but we can also use these variables as values in our shell commands. To do so, we prefix the variable with the dollar sign. For example, we print out the HOME variable’s value using the code below:

$
...