Linux Environment Variables
Managing system and user environment variables, PATH configuration, and variable scope in Linux shell environments
- Category
- Linux
- Level
- basic
- Languages
- en → en
- Cards
- 49
- Markdown
- Linux Environment Variables (.md)
Flashcards (49)
| # | Front (Term / Question) | Back (Definition / Answer) | Example | Multiple-Choice Options |
|---|---|---|---|---|
| 1 | What does the variable BASH_VERSION indicate? | BASH_VERSION indicates the version of the Bash shell currently in use. | ||
| 2 | What is the purpose of the variable IFS? | IFS (Internal Field Separator) defines the character(s) used to split input into fields. | ||
| 3 | How can you reset an environment variable to its default? | You can reset it by unsetting it and then re-exporting it if necessary. | ||
| 4 | What does the variable PATH represent? | PATH is a colon-separated list of directories that the shell searches for executable files. | ||
| 5 | What does the variable PS1 represent? | PS1 defines the primary prompt string in the shell. | ||
| 6 | What is the difference between local and global environment variables? | Local variables are available only in the current shell session, while global variables are accessible in all child processes. | ||
| 7 | How can you view the current shell's prompt settings? | You can view the prompt settings by echoing the PS1 variable: 'echo $PS1'. | ||
| 8 | How do you check the value of an environment variable in a script? | You can check it using 'echo $VARIABLE_NAME' within the script. | ||
| 9 | How can you view the environment variables in a script? | You can view them by using 'printenv' or 'env' commands within the script. | ||
| 10 | What is an environment variable in Linux? | An environment variable is a dynamic value that can affect the way running processes will behave on a computer. | ||
| 11 | How can you make an environment variable permanent? | You can add it to configuration files like '.bashrc', '.bash_profile', or '/etc/environment'. | ||
| 12 | How can you view the value of the PATH variable? | You can view it by executing 'echo $PATH'. | ||
| 13 | What is the command to unset an environment variable? | You can unset an environment variable using 'unset VARIABLE_NAME'. | ||
| 14 | How do you check the scope of a variable in a script? | You can check the scope by observing if it is accessible in subshells or child processes. | ||
| 15 | What does the variable HISTFILE represent? | HISTFILE specifies the file where the command history is saved. | ||
| 16 | How can you check if a variable is set? | You can check if a variable is set using 'if [ -z $VARIABLE_NAME ]; then echo not set; fi'. | ||
| 17 | What is the difference between 'set' and 'export' commands? | 'set' lists all shell variables, while 'export' marks a variable for export to child processes. | ||
| 18 | What is the effect of using 'export -n'? | 'export -n' removes the export property from a variable, making it local to the current shell. | ||
| 19 | What is the effect of exporting a variable? | Exporting a variable makes it available to all child processes of the current shell. | ||
| 20 | What is the effect of using 'set +x' in a script? | 'set +x' disables the printing of commands as they are executed. | ||
| 21 | What is the significance of the SHELL environment variable? | The SHELL variable indicates the path of the current user's shell. | ||
| 22 | How do you append a directory to the PATH variable? | You can append a directory by using 'export PATH=$PATH:/new/directory'. | ||
| 23 | What is the purpose of the variable GROUPS? | GROUPS lists the groups that the current user belongs to. | ||
| 24 | What is the effect of using 'readonly' on a variable? | 'readonly' makes a variable immutable, preventing it from being changed. | ||
| 25 | What is the effect of using 'set -x' in a script? | 'set -x' enables a mode of the shell where all executed commands are printed to the terminal. | ||
| 26 | What does the variable DISPLAY represent in a graphical environment? | DISPLAY specifies the X server to connect to for graphical applications. | ||
| 27 | What is the purpose of the variable HISTSIZE? | HISTSIZE defines the number of commands to remember in the command history. | ||
| 28 | How do you create a new environment variable? | You create a new environment variable using 'export NEW_VARIABLE=value'. | ||
| 29 | What command is used to set an environment variable in Linux? | You can set an environment variable using the command 'export VARIABLE_NAME=value'. | ||
| 30 | How do you export multiple variables at once? | You can export multiple variables using 'export VAR1=value1 VAR2=value2'. | ||
| 31 | What does the variable PWD represent? | PWD represents the current working directory. | ||
| 32 | How do you remove an environment variable from the current session? | You can remove it using 'unset VARIABLE_NAME'. | ||
| 33 | How can you view all environment variables in a Linux shell? | You can view all environment variables by using the command 'printenv' or 'env'. | ||
| 34 | What is the difference between 'set' and 'env' commands? | 'set' shows shell variables and functions, while 'env' shows environment variables. | ||
| 35 | What command would you use to list all exported variables? | You can use the command 'export -p' to list all exported variables. | ||
| 36 | What does the variable EDITOR specify? | EDITOR specifies the default text editor to be used by command-line applications. | ||
| 37 | How can you create a variable that is only available in the current shell session? | You can create it simply by 'VARIABLE_NAME=value' without using 'export'. | ||
| 38 | What is the purpose of the LD_LIBRARY_PATH variable? | LD_LIBRARY_PATH specifies a list of directories where the linker should look for dynamic libraries. | ||
| 39 | What does the variable LANG control? | LANG controls the locale settings for language and regional preferences. | ||
| 40 | How can you temporarily set an environment variable for a single command? | You can set it inline, e.g., 'VARIABLE=value command'. | ||
| 41 | How can you check the value of a specific environment variable? | You can check the value using 'echo $VARIABLE_NAME'. | ||
| 42 | What is the difference between a user variable and a system variable? | User variables are specific to a user session, while system variables are available to all users and processes. | ||
| 43 | What is the purpose of the PATH environment variable? | The PATH variable specifies a list of directories where the shell looks for executable files. | ||
| 44 | What does the TERM environment variable specify? | The TERM variable specifies the type of terminal to emulate when running the shell. | ||
| 45 | What does the HOME environment variable represent? | The HOME variable represents the current user's home directory. | ||
| 46 | How can you view the current user's environment variables in a graphical interface? | You can view them in system settings or environment configuration tools, depending on the desktop environment. | ||
| 47 | What does the variable TERMINFO specify? | TERMINFO specifies the directory containing terminal capability descriptions. | ||
| 48 | What does the variable USER represent? | USER represents the name of the currently logged-in user. | ||
| 49 | What is the purpose of the variable MAIL? | MAIL specifies the location of the user's mailbox. |