Custom Shell Prompt

I use this whenever I set up a new RedHat server.  I add it to the end of the /etc/bashrc file and it gives me the FQDN of the host.  I have a habit of using "web" or "server1" across a lot of different servers.  This helps me to be aware of whether I'm on (ie. or

# If id command returns zero, you’ve root access.
if [ $(id -u) -eq 0 ];
then # you are root make the prompt red and present FQDN
  PS1="[$(tput setaf 1)]u@H:w #[$(tput sgr0)] "
else # black except use "H" instead of "h" for FQDN
  PS1="[u@H:w $ "


This entry was posted in CLI HOWTOs, HOWTOs. Bookmark the permalink.