As you can see from the screenshot, my entire machine name (looks like a key) gets displayed whenever I invoke a terminal session.

Is there any way to avoid or hide it?


Yes. Open ~/.bashrc file from terminal with:

gedit ~/.bashrc

Find this line (in my case is somewhere at line 60):

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

and replace it with:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

As you can see, the most important thing is to delete \h (which stands for hostname) from PS1 if you want to hide machine name from displaying in terminal.

Save the file and close it. Restart the terminal, or just type:

. ~/.bashrc
  • 1
    \h means hostname, right? – Braiam Aug 28 '13 at 22:44
  • 2
    @Braiam yes, as well as \u means username. – amertkara Sep 10 '15 at 18:58
  • 2
    Can I do the same with the terminal window title? – Ivan Sep 4 '16 at 17:56
  • Worked for me in Ubuntu 19.10 – Shantanu Tomar Mar 28 '20 at 10:15
  • If you want to remove it from the window title as well, do the same in the section next to that line (where it checks whether it is an xterm or not, line 69). – Gevorg Melkumyan Dec 13 '20 at 9:56

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.