Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

Bash Environment Variables

May 24, 2023 — Gregg Szumowski

Here are some bash environment variables that are useful to know when you're using the command prompt:

$0 - name of shell or shell script
$1, $2, $3, ... - positional parameters to script
$# - count of positional parameters
$? - exit status of most recent foreground task
$- - current options that are set for the shell
$$ - PID of the current shell (not subshell)
$! - the PID of the most recent background command
$DESKTOP_SESSION - path to the current display manager
$EDITOR - preferred text editor
$LANG - current language
$PATH - directory list to search for executables (programs)
$PWD - current working directory
$SHELL - current shell
$USER - current username
$HOME - current user's home directory
$HOSTNAME - current name of the host
$TERM - current terminal

Tags: cli, bash, motd