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
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
You have to define the PS1 variable on the client system and make sure the definition is sourced when you
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
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
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
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
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:
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:
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.
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
You can make changes permanent by editing /etc/bash.bashrc and appending your changes with your favorite editor
Sources: this page and testing.