$HOME
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"
OR
printf "%s\n" $HOME
Sample outputs:
/home/vivek
Use the current value of $HOME in your shell script
Creating and setting $HOME within a script is fairly simple. Use the following syntax:
varName=$HOME
For example:
#!/bin/bash
mysweethome="$HOME"
echo "Your home directory is located at $HOME"