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?
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.
\u@\h \w
as variables. I also can't use the up or down arrows, instead I see ^[[A
.
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.
Commented
Apr 17, 2011 at 2:11