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