Exploring $HOME/.profile

: ${HOME='/root'} # no error message
  • If HOME is not set, assign ‘/root’ to HOME and $HOME will be substituted with /root
  • The colon lets you set HOME without printing an error message. The command interpreter tries to execute $HOME, which is substituted as /root, which by itself is not a command.
${TEST='ls'}
$TEST
  • TEST isn’t set, so it is assigned ‘ls’ and substituted. The command interpreter recognizes ‘ls’ as a command and lists the directory. Same deal with $TEST by itself.
echo ${HOME='/bin'}
  • This returns /root
  • If HOME is already set, $HOME is substituted with ‘/root’.
  • If HOME is not set, then HOME is assigned ‘/bin’ and substituted.
umask 022
  • The umask command sets the bits to be turned off on file creation.
  • 022 turns off write permissions for group and others.
  • As umask(2) states, “write access for the owner only.”