1.3 Environment Variables Flashcards
How do you preserve the current value of the PATH environment variable when adding a new value to it?
To preserve the current value of the PATH environment variable when appending paths to it, put $PATH. For example, PATH=$PATH:/additional/path.
What are the two different types of variables?
The two different types of varables are user-defined variables and environment variables.
What is a user-defined variable?
Variables assigned with a name and contents of your choice. Does not change the shell environment or how the shell works.
What is an environment variable?
An environment variable is a setting that the operating system or programs working in the operating system access. Environment variables make up the user environment.
What is the standard for environment variable names?
The standard for writing variables names (called variable identifiers) is to use all upper-case letters (e.g., SHELL and EUID).
What do environment variables become when you change them from the defaults?
Changing environmental variables from the defaults result in user-defined variables.
What is a user-defined variable?
A user-defined variable is a variable that applies only to the current session.
How do you make a user-defined environement variable apply to child sessions?
Exporting user-defined variables makes them apply to child sessions.
How do you make user-defined environment variables persistent?
Add user-defined variables to the shell configuration files to make them persistent.
What does the BASH environment variable contain?
The BASH environment variable contains the location of the bash executable file.
What does the SHELL environment variable contain?
The SHELL environment variable contains the user’s login shell.
What does the CPU environment variable contain?
The CPU environment variable contains the type of CPU.
What does the DISPLAY environment variable contain?
The DISPLAY environment variable contains the location where X Windows output goes. Can be used to send X-windows output to another machine.
What does the ENV environment variable contain?
The ENV environment variable contains the location of the configuration file for the current shell.
What does the EUID environment variable contain?
The EUID environment variable contains the ID number of the current user.
What does the HISTFILE environment variable contain?
The HISTFILE environment variable contains the filename where past commands are stored. For Bash, it’s usually ~/.bash_history.
What does the HISTSIZE environment variable contain?
The HISTSIZE environment variable contains the number of past commands that HISTFILE stores for the current session.
What does the HISTFILESIZE environment variable contain?
The HISTFILESIZE environment variable contains the number of past commands that HISTFILE stores for the multiple sessions.
What does the HOME environment variable contain?
The HOME environment variable contains the absolute path of the user’s home directory.
What does the HOST environment variable contain?
The HOST environment variable contains the name of the computer.
What does the HOSTNAME environment variable contain?
The HOSTNAME environment variable contains the name of the computer. It is identical to HOST, but used on certain distributions.
What does the INFODIR environment variable contain?
The INFODIR environment variable contains the path to the computer’s information pages.
What does the LOGNAME environment variable contain?
The LOGNAME environment variable contains the user name of the current user.
What does the MAIL environment variable contain?
The MAIL environment variable contains the path to the current user’s mailbox file. Usually /var/spool/mail/username.
What does the MANPATH environment variable contain?
The MANPATH environment variable contains the path to the computer’s man pages. Usually /usr/local/man.
What does the OLDPWD environment variable contain?
The OLDPWD environment variable contains the path of the directory the user was in prior to the current path.
What does the OSTYPE environment variable contain?
The OSTYPE environment variable contains the type of operating system. Usually this is Linux.
What does the PATH environment variable contain?
The PATH environment variable contains the directory prefixes used to search for programs and files:
- Use a colon (:) to separate entries in the PATH variable.
- Do not include a period (.) in the PATH variable. A period indicates that the working directory is in the path, and this poses a security risk.
What does the PS1 environment variable contain?
The PS1 environment variable contains the characters the shell uses to indicate normal user ($), root user (#) and similar items.
What does the PWD environment variable contain?
The PWD environment variable contains the path of the current working directory.
What does the LANG environment variable contain?
The LANG environment variable contains the language the operating system uses.
What does the PAGER environment variable contain?
The PAGER environment variable contains used by the man command to specify the program in which to display man pages.
What does the command echo $variable do?
Views the variable’s value.
What does the command env do?
Displays names and values only for environment variables applied to child sessions. In other words, variables that have been exported.
What does the command set do?
Sets or displays shell environment variables. Without options, displays names and values of all environment variables on the system.
What does the command unset variable do?
Removes an environment variable.
What does the command VARIABLE=value do?
Creates a user-defined environment variable.
What does the command export variable do?
Exports a user-defined variable to make it available to child sessions.
How do you append information to an existing environment variable?
To append information to an environment variable, put the current variable in the command. For example, PATH=$PATH:/bin/additionalpath.