4

My question is pretty silly, but could not find nothing on the internet that explained me how. The thing is that I want to have the name displayed in the terminal as: Server mpi@raspberry: ... $ but can not find how to add the "name" Server to the user (I am calling that the name, but probably it is not correct). Instead, my terminal shows mpi@raspberry: ... $

3
  • 1
    Do you want to change the actual user name, or just how it is displayed in the prompt? For the latter, look up the PS1 variable
    – Panki
    Jun 21 at 10:07
  • Assuming raspberry is the hostname, mpi is the username , then Server is a hardcoded word you want to PREPEND ? In that case, echo $PS1 will show you what the current PS1 value is, then copy paste that to export PS1="Server <<current value of PS1>>" and check whether this is what you want ?
    – Prem
    Jun 21 at 10:35
  • is this "name" a variable or just a static prefix you want added to your name?
    – Alko
    Jun 21 at 13:49

2 Answers 2

3

Explaining further the answer of kodcode:

In order to add an alias, we have to enter to each user and write sudo gedit ~/.bashrc, then we will see a lot of things written on this file, but the importante line to change is:

if [ "$color_prompt" = yes ]; then
    PS1='\[\033[1;33m\]Alias ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

Replace Alias by the alias that you want and copy the code to the file replacing in the original file from the beginning of the if, until fi. This will help to know at which device we are connecting to.

-1

You can use this online tool to create a customized prompt:

https://bashrcgenerator.com/

You want the "hostname" to be displayed.

4
  • 1
    Welcome to StackExchange ; +1 for the rc generator tool !
    – Prem
    Jun 21 at 10:37
  • 4
    -1 for link only answer Jun 21 at 10:41
  • 1
    Thanks! it really helped! Jun 21 at 11:59
  • That's what counts :)) @EnzoBasile
    – kodcode
    Jun 21 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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