Add history with a timestamp and increase history commands size, for example in /etc/bashrc or ~root/.bash_profile:
export HISTSIZE=10000 export HISTTIMEFORMAT="%F %T "
http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
http://www.understudy.net/custom.html
So when executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command. Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:
| Sequence | Description | 
|---|---|
| \a | The ASCII bell character (you can also type \007) | 
| \d | the date in “Weekday Month Date” format (e.g., “Tue May 26”) | 
| \D{format} | the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required | 
| \e | an ASCII escape character (you can also type \033) | 
| \h | First part of hostname (such as “mybox”) | 
| \H | Full hostname (such as “mybox.mydomain.com”) | 
| \j | The number of processes you've suspended in this shell by hitting CTRL+Z | 
| \l | the basename of the shell’s terminal device name (such as “ttyp4”) | 
| \n | newline | 
| \r | carriage return | 
| \s | The name of the shell executable (such as “bash”) | 
| \t | the current time in 24-hour HH:MM:SS format | 
| \T | the current time in 12-hour HH:MM:SS format | 
| \@ | the current time in 12-hour am/pm format | 
| \A | the current time in 24-hour HH:MM format | 
| \u | the username of the current user | 
| \v | the version of bash (e.g., 2.04) | 
| \V | Bash version, including patchlevel | 
| \w | the current working directory, with $HOME abbreviated with a tilde | 
| \W | the basename of the current working directory, with $HOME abbreviated with a tilde | 
| \! | Current command's position in the history buffer | 
| \# | Command number (this will count up at each prompt, as long as you type something) | 
| \$ | if the effective UID is 0, a #, otherwise a $ | 
| \nnn | Command number (this will count up at each prompt, as long as you type something) | 
| \\ | a backslash | 
| \[ | begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt | 
| \] | end a sequence of non-printing characters | 
A list of handy tput command line options
  tput bold - Bold effect
  tput rev - Display inverse colors
  tput sgr0 - Reset everything
  tput setaf {CODE}- Set foreground color, see color {CODE} table below for more information.
  tput setab {CODE}- Set background color, see color {CODE} table below for more information.
Various color codes for the tput command
| Color {code} | Color | 
|---|---|
| 0 | Black | 
| 1 | Red | 
| 2 | Green | 
| 3 | Yellow | 
| 4 | Blue | 
| 5 | Magenta | 
| 6 | Cyan | 
| 7 | White | 
Let us try to set the prompt so that it can display today’d date and hostname:
PS1="\d \h $ "
Output:
Sat Jun 02 server $
Now setup prompt to display date/time, hostname and current directory:
$ PS1="[\d \t \u@\h:\w ] $ "
Output:
[Sat Jun 02 14:24:12 vivek@server:~ ] $
Append the code as follows
# If id command returns zero, you’ve root access. if [ $(id -u) -eq 0 ]; then # you are root, set red colour prompt PS1="\\[$(tput setaf 1)\\]\\u@\\h:\\w #\\[$(tput sgr0)\\]" else # normal PS1="[\\u@\\h:\\w] $" fi
Other samples:
export PS1='\[33[0;32m\][\u@\h \W]\$\[33[0m\] ' export PS1="\[\e[0;31m\][\u@\h \w]\$ \[\e[m\]" export PS1="\e[0;31m[\u@\h \W]\$ \e[m " export PS1=’\[\e[0;32m\]\u@\h:\w\$ \[\e[0m\]’ export PS1="\[$(tput setaf 1)\]\u@\h:\w $ \[$(tput sgr0)\]"