13. Bourne and Bash Shells' Environment Variables
Contents
The shell that Linux used in the first place was Bourne, and then Linux released Bash, which is an enhanced version of Bourne, and most Linux systems now use Bash by default.
Bourne Shell Variables
Home and path are the two most commonly used bourne shell variables
HOME
Current user’s home directory.
|
|
PATH
Paths of binary files, which are runnable programs.
|
|
Bash Variables
The number of environment variables in bash is so large that only a few commonly used ones are listed here:
BASH
Print the directory where bash is stored.
|
|
BASH_VERSION
Prints bash’s version
|
|
BASHPID
Current Bash’s process ID.
|
|
GROUPS
Current user’s group IDs:
|
|
HISTFILE
The directory of history file:
|
|
HISTFILESIZE
The allowed lines contained in the history file:
|
|
HISTSIZE
The allowed lines contained in the history list:
|
|
HOSTNAME
Current host’s name:
|
|
HOSTTYPE
Current machine type:
|
|
LINENO
The line number that the current shell or script is running:
|
|
MACHTYPE
The CPU architecture, company name, and type of the system which Bash is running:
|
|
OSTYPE
The operating system that Bash is running on:
|
|
PPID
The shell’s parent’s process ID:
|
|
Switch to a new shell:
|
|
Check parent shell’s process ID:
|
|
RANDOM
Generate a random integer number between 0 and 32767
|
|
SECONDS
The number of seconds since shell started:
|
|
SHELL
The full path of the shell we are using
|
|
SHLVL
The deep level of the current shell, every time a new instance of bash is started, the variable incremented by one:
|
|
Switch to a new bash, this starts a new bash instance:
|
|
Check current bash’s deep level:
|
|
UID
The user ID of the current user:
|
|
References 5.1 Bourne Shell Variables, 5.2 Bash Variables
Author Dong Chen
LastMod Thu Feb 14 2019