From Linux Bash Shell Scripting Tutorial Wiki
Jump to navigation Jump to search

$HOME is a Linux bash shell variable. It indicates the home directory of the current user; the default argument for the cd command. The value of this variable is also used when performing tilde expansion. Do not change the value of $HOME.

See the current value of $HOME

Use the echo command or printf command as follows:

echo "$HOME"


printf "%s\n" $HOME

Sample outputs:


Use the current value of $HOME in your shell script

Creating and setting $HOME within a script is fairly simple. Use the following syntax:


For example:

echo "Your home directory is located at $HOME"