Linux+ 1.3 Environment Variables

15 terms by WilliamWaterman 

Create a new folder

Advertisement Upgrade to remove ads

Linux+ Certification

Environment Variable Facts

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. Be aware of the following details:

The standard for writing variables names (called variable identifiers) is to use upper case (e.g., SHELL and EUID)
Changing environmental variables from the defaults result in user-defined variables.
A user-defined variable applies only to the current session; export the user-defined variables so they apply to child sessions.
Add user-defined variables to the shell configuration files to make them persistent.

Common Environment Variables

BASH The location of the bash executable file
SHELL The user's login shell.
CPU The type of CPU.
DISPLAY Location where X Windows output goes.
ENV The location of the configuration file for the current shell.
EUID The ID number of the current user.
HISTFILE The filename where past commands are stored.
HISTSIZE The number of past commands that HISTFILE stores for the current session.
HISTFILESIZE The number of past commands that HISTFILE stores for the multiple sessions.
HOME The absolute path of the user's home directory.
HOST The name of the computer.
HOSTNAME HOSTNAME is identical to HOST, but used on certain distributions.
INFODIR The path to the computer's information pages.
LOGNAME The user name of the current user.
MAIL The path to the current user's mailbox file.
MANPATH The path to the computer's man pages.
OLDPWD The path of the directory the user was in prior to the current path.
OSTYPE The type of operating system. Usually this is Linux.
PATH 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.

PS1 The characters the shell uses to indicate normal user ($), root user (#) and similar items.
PWD The path of the current working directory.
LANG The language the operating system uses.
PAGER Used by the man command to specify the program in which to display man pages.

The table below lists the most common environment variable commands:

echo $variable View the variable's value. echo $SHELL displays the current shell's path.
env Display the values for environment variables applied to child sessions.
set Set shell environment variables. Without options, set displays the set environment variables for the system.
unset variable Remove an environment variable. unset HOMEDIR removes the HOMEDIR variable.
VARIABLE=value Create a user-defined environment variable.
Note: To append information to an environment variable, put the current variable in the command. For example, PATH=$PATH:/bin/additionalpath. HOMEDIR=/projects gives the HOMEDIR variable a value of /projects.
export variable Export a user-defined variable to make it available to child sessions. export HOMEDIR makes the HOMEDIR user-defined variable available to child sessions.
PATH=$PATH:/bin/special ; export PATH appends a directory to PATH and immediately exports the variable.

You want to view the number of commands your HISTSIZE environment variable is set to save. You don't want to have to scroll through all the environmant variables. Which command shows you the value for the HISTSIZE variable?

echo $HISTSIZE

Two users should have identical settings, yet one is having problems with the display on his screen and you suspect there is a difference in their environment variables. Which command will display all the environment variables?

env

You recently used the HOST=FS4 command. What command should you use to make the environment variable apply to all sessions?

export HOST

Which command shows the value of the environment variable currently set for the terminal?

echo $TERM

You want the directory /sbin/special to always be a part of the PATH. You also want to keep all the current entries in your PATH statement. Which command would you use?

PATH=$PATH:/sbin/special

Which environment variable affects the number of past commands used in the current shell?

HISTSIZE

Which of the following commands best describes the PATH environment variable?

It contains the directory prefixes used to search for program files.
It specified the filename where past commands are stored.
It specifies the characters the shell used to indicate normal user ($), root user (#) and similar items.
It contains the path of the current working directory.

It contains the directory prefixes used to search for program files.

Which command will display all the environment variables in the system?

set

Which command will display only the environmant variables applied to child sessions?

env

You need to set the COMP variable to the value of 1745. Which command will set the variable so it is available to other programs?

set COMP to 1745
set COMP=1745
COMP=1745
export COMP=1745

export COMP=1745

Which of the following commands will configure the shell to retain 300 recently-used commands in the ~/.bash_history file for multiple shell sessions?

BASH=300
HISTSIZE=300
HISTFILESIZE=300
HISTFILE=300

HISTFILESIZE=300

Which of the following presents the greatest security risk?

There are several disabled user accounts.
The system has a large file named core.
The PATH statement includes . (period).
The second field for every user in the /etc/passwd file is x.

The PATH statement includes . (period).

Please allow access to your computer’s microphone to use Voice Recording.

Having trouble? Click here for help.

We can’t access your microphone!

Click the icon above to update your browser permissions above and try again

Example:

Reload the page to try again!

Reload

Press Cmd-0 to reset your zoom

Press Ctrl-0 to reset your zoom

It looks like your browser might be zoomed in or out. Your browser needs to be zoomed to a normal size to record audio.

Please upgrade Flash or install Chrome
to use Voice Recording.

For more help, see our troubleshooting page.

Your microphone is muted

For help fixing this issue, see this FAQ.

Star this term

You can study starred terms together

NEW! Voice Recording

Create Set