10 Shell and environment variables Flashcards
Set variable to value:
variable=value
Make variable visible to called programs:
export variable
export variable=value
Modify environment variables for one command only:
variable1=value variable2=value command
shows all shell variables
set
shows all (exported) environment variables.
printenv
home directory
$HOME
~
Your login name.
$USER/$LOGNAME
Colon-separated list of directories in which shell looks for commands (e.g., “/bin:/usr/bin:/usr/X11R6/bin”).
Should never contain “.”, at least not at beginning. Why?
$PATH
Colon-separated list of directories where the loader looks for shared libraries (see man ld.so)
$LD_LIBRARY_PATH
.. C security issue
Locale
$LANG, $LC_*
Your “locale”, the name of a system-wide configuration file with information about your character set and language/country conventions (e.g., “en_GB.UTF-8”). $LC_* sets locale only for one category, e.g. $LC_CTYPE for character set and $LC_COLLATE for sorting order; $LANG sets default for everything. “locale -a” lists all available locales.
Specification of your timezone (mainly for remote users)
$TZ
Previous working directory, also available as “~-”
$OLDPWD
Change the command prompt
$PS1 — The normal command prompt, e.g.
$ PS1=’[\033[7m]\u@\h:\W !$[\033[m] ‘
Printers
$PRINTER — The default printer for lpr, lpq and lprm.
Terminal type
$TERM — The terminal type (usually xterm or vt100).