Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

root@Machine:/current/path#:

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?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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