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
$) 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.