0

This question already has an answer here:

Every time I open my terminal, I see xyz@abc where I type my sudo commands.However, my concern is this xyz and I want to change it to the name of my choice. I am unaware of the technical term for this and also the steps to do this.I am using ubuntu 18.04.

marked as duplicate by Sergiy Kolodyazhnyy command-line Jan 19 at 9:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

What you see (xyz@abc) is the bash prompt:

  • xyz is the username

  • abc is the hostname

You can tune it by modifying the variable PS1 in the file ~/.bashrc. You may see the Ubuntu documentation: Customizing Bash Prompt.

Simply open ~/.bashrc file in a text editor like nano, create new line filled with a copy of the PS1 definition. For your need, you will replace the \u username tag by coco if you want to see coco in place of xyz.

Inside of ~/.bashrc:

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

Some readings:

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