When I ssh as root to a remote machine, the command output looks like this:


However, if it's a non-root user, all I see is:


How can I get the same behavior as for the root user? Why is it different?


The "command output" that you referred to is called "the prompt". At the end of the prompt usually there is a character (in bash usually # or $) to indicate the end of the prompt and the start of user input. It is different so that you know if you are the root user or not. Generally when you see a # at the end of you prompt you know that you are root and should be careful with your commands.

Controlling the prompt depends on the shell that you use. For bash you use the environment variable PS1 to do so. For example if you run:

export PS1='\u@\h \w \$ '

Your next prompt will change to something like:

phunehehe@workstation ~/Desktop $ 

Refer to the PROMPTING section in man bash for the format of the PS1 variable. A point of interest to your question:

\$     if the effective UID is 0, a #, otherwise a $

To change the prompt permanently, put the export line in /etc/profile (system-wise), or ~/.profile (user-wise), or something equivalent.

  • Thanks, that makes sense. However, my ssh session is still broken. When I am logged in as user, it doesn't evaluate \u@\h \w as variables. I also can't use the up or down arrows, instead I see ^[[A. – m33lky Apr 16 '11 at 19:44
  • What is your shell? Other shells may have different format to the PS1 variable. Check this question in case you don't know. About the up and down arrows, I think it has little to do with the prompt. You should ask that in another question. – phunehehe Apr 17 '11 at 2:11
  • I am asking this here. – m33lky Apr 17 '11 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.