Prompts

M

MustangV10

Guest
Can anyone explain to me about Linux SSH prompts? Such as, root@server [~]# - I believe that's what someone called them once..Something to do with ps1/ps2 prompts as well.

Thanks.
 


Disclaimer: I'm not sure what distro you're on and what your shell is, but I'm only really familiar with BASH--if you're not using it, you're probably using dash or something similiar which probably behaves exactly the same way. ...

Open up a terminal and run this: echo $PS1
That string there is what is configuring your bash prompt. To find out more about it check out man bash and then search (type a forward slash to get a search prompt) for the big section on PROMPTING.
Here's an example. Try running this to see what my prompt looks like when I'm logged in as root (my PS1 variable):
PS1='\[\033[0;31m\]\u\[\033[0;33m\]@\h\[\033[0;36m\]:\W\$\[\033[0;0m\] '

Almost forgot. To make a change like this permanent for one user, the appropriate place would be ~/.bashrc; alternatively, you could change it for everyone by dropping it into a new arbitrarily-name file in profile.d, i.e., /etc/profile.d/ps1.sh, with content like so:

Code:
if [ $UID -eq 0 ]; then                                                                                                                                                          
  PS1='\[\033[0;31m\]\u\[\033[0;33m\]@\h\[\033[0;36m\]:\W\$\[\033[0m\] ' 
else
  PS1='\[\033[0;33m\]\u@\h\[\033[0;36m\]:\W\$\[\033[0m\] '
fi
 

Members online


Top