Recall & Review
beginner
What is an environment variable in Linux?
An environment variable is a named value stored by the operating system that programs can use to get information about the system or user settings. It acts like a note that programs can read to know how to behave.
Click to reveal answer
beginner
How do you display all environment variables in a Linux shell?
You can use the command
printenv or env to list all environment variables currently set in your shell session.Click to reveal answer
beginner
How do you set a new environment variable for the current shell session?
Use the command
export NAME=value. For example, export MYVAR=hello sets an environment variable named MYVAR with the value 'hello' for the current session.Click to reveal answer
intermediate
What happens to environment variables when you close the terminal?
Environment variables set in a terminal session are lost when you close that terminal unless saved in configuration files like
~/.bashrc or ~/.profile to load automatically on new sessions.Click to reveal answer
beginner
How can you use an environment variable inside a shell script?
You can access an environment variable in a shell script by prefixing its name with a dollar sign, like
$VARIABLE_NAME. For example, echo $HOME prints the home directory path.Click to reveal answer
Which command shows all environment variables in Linux?
✗ Incorrect
The
printenv command lists all environment variables. Other commands like ls, cd, and mkdir do not show environment variables.How do you set an environment variable named PATH to '/usr/bin' for the current session?
✗ Incorrect
Use
export PATH=/usr/bin to set and export the variable so child processes can see it. Just PATH=/usr/bin sets it only for the current shell, not exported.What symbol do you use to access the value of an environment variable in a shell script?
✗ Incorrect
The dollar sign
$ is used to access the value of an environment variable, e.g., $HOME.Where should you save environment variable settings to make them permanent for your user?
✗ Incorrect
User-specific environment variables are often saved in
~/.bashrc or ~/.profile to load automatically on new shell sessions.If you set an environment variable in one terminal, will it be available in a new terminal window automatically?
✗ Incorrect
Environment variables set in one terminal session are not available in new terminals unless saved in configuration files like
~/.bashrc.Explain what environment variables are and how they are used in Linux.
Think about how programs know about your system or preferences.
You got /4 concepts.
Describe the steps to create a new environment variable that lasts across terminal sessions.
Consider both temporary and permanent ways.
You got /3 concepts.