How to hide username in terminal Ubuntu

You might be in scenarios where you might want to hide your username or computer name or current working directory in your Ubuntu. I will walk you through a step-by-step easy procedure to do achieve that.

Open bashrc by using the below command. There are multiple ways to open bashrc, you can use any text editor like vim, nano etc. But here we are using a gedit a GUI based text editor which may not be a favourite text editor for everyone, but it does the job well and easily.

gedit ~/.bashrc
gedit ~/.bashrc to open in gedit.

Once the bashrc is opened in the gedit window,scroll down to the end of the bashrc file like the below screenshot.

bashrc content in gedit.

At the end of the file, add a new line by clicking the Enter button and type the below statement.

export PS1="\W \$"
updated bashrc content

After adding the text type Ctrl+S (Save the file) and close the text editor. 

Then run the below command

source ~/.bashrc

Which will refresh the bashrc file to reflect the new changes. Is kind of important setup without this your new changes won’t be reflected.

refresh bashrc after editing

Once done, close your terminal and open a new terminal, which should look like the below the screenshot.

final result terminal.

© 2022, Datalieve . All rights reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *

You cannot copy content of this page