0

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.

1 Answers1

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:

pa4080
  • 29,831
cmak.fr
  • 8,696