I'm using Ubuntu Server over SSH, and I see $
instead of the name of the user (let's say test@desktop
, for example).
How can I make the terminal display test@desktop
instead of $
?
I'm using Ubuntu Server over SSH, and I see $
instead of the name of the user (let's say test@desktop
, for example).
How can I make the terminal display test@desktop
instead of $
?
PS1="/u@/h"
will give you what you are asking for although I don't recommend that you do this as it will make it difficult to ascertain if you are in standard or superuser mode.
To change it back to the default for 16.04 (and earlier?) use PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$"
You can make changes permanent by editing /etc/bash.bashrc and appending your changes with your favorite editor
Sources: this page and testing.
"
and this sets the prompt to literally test@desktop
not user@host
;)
– Zanna
Aug 19 '16 at 18:41
You have to define the PS1 variable on the client system and make sure the definition is sourced when you ssh
.
It's possible that it is already defined in .bashrc
on the remote system and so you just need to source .bashrc
by starting an interactive shell (replace remote-sys
with your remote system's name obviously)
ssh remote-sys -t bash -i
If that doesn't work, because .bashrc
doesn't exist on the remote system, or doesn't have PS1 defined, and you want to use the same settings on the remote system as your local system, then copy over your own .bashrc
:
scp ~/.bashrc remote-sys:.bashrc
Or you can make a file purely to set the prompt the way you want it on the remote system... for example
nano .set-prompt
enter the text (this sets user@host as the prompt)
export PS1="\u@\h "
or if you want it to look like the Ubuntu prompt user@host:working-directory$
export PS1="\u@h:\w$ "
or customise however you like. Save the file and exit, then scp
it to the remote system
scp .set-prompt remote-sys:.set-prompt
When you ssh
to the machine you will have to source the file explicitly and tell bash to make the shell interactive:
ssh remote-sys -t "bash --rcfile ~/.set-prompt -i"
If you do sudo -i
to change to root on the remote system, the prompt will change again as root's .bashrc
will be sourced.
If you're SSH-ing into a sh
session, which I think is the case judging by what you have currently, you can add variables and commands to your PS1:
PS1='$USER@$(hostname)\$ '
If you're SSH-ing into a bash
session, you have endless options, but I'd recommend to use the default if you're just getting into this. To set the PS1 in only the current session, run this:
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
To make the change permanent, open the ~/.bashrc
on the remote machine and add the above line to it.
See Where can I find a complete reference for the $PS1 variable? to understand what the above line does.
P.S. I don't use SSH very much myself, so you may have to change some other settings to make this stuff work.
.profile
is only sourced if .bash_profile
and .bash_login
don't exist... and this is all on the remote system, not local, of course
– Zanna
Aug 19 '16 at 17:36
/bin/bash
– earthmeLon Aug 19 '16 at 17:45