Remove Your Computer’s Name From your Bash/Terminal on Ubuntu

Happen to be trying to remove your computer’s name from your bash/terminal on Ubuntu? I thought it was an eyesore when I was writing up some docs and was taking screenshots. I did some research and thought I’d pass along what I learned.

My Setup

  • Windows 10 Ubuntu Subsystem

Edit your hidden .bashrc file!

So this will all be via command line because, why not? We’re going to use nano for the next change. Why not VIM? I’m not sure… maybe because I don’t know how to exit out of it yet?

So, execute the following to open up your .bashrc file.

nano ~/.bashrc

This will open up the file which holds your bash settings. We’ll be making changes to this file to remove our computer’s name. This is what my own looks like prior to the changes.

We’re going to remove DESKTOP-S28UEBE because that’s just a waste of good space. So you’re in your bashrc file. This is the section we’ll be looking for.

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

We need to remove the two \h in this section. I removed both, we may be able to get away with only removing one or the other. Feel free to test and let us know what you experience! So remove the \h’s. Then hit ctrl+x to exit nano. It’ll ask you if you want to save. Hit Y and then the enter key. The window you opened the file with will not have changed but each subsequent terminal should no longer have your machine’s name next to your username!

No more ugly! Now you know how to remove your computer’s name from your bash/terminal on ubuntu. Happy coding! Want more bash stuff? Checkout this git post.

Leave a Comment Cancel reply

Exit mobile version