How to hide or change “username @ localhost:” in terminal

Some people are obsessed with privacy and security. They always play safe. They never show any person on the Internet. If you are one of them, we have a little tip to add protection to your privacy. If you are a blogger or tech writer, chances are that you will need to upload screenshots of your Linux terminal for your websites and blogs. As you already know, terminal in Linux shows username and hostname. Take a look at the following screenshot.

Here, sk username and ubuntuserver hostname.

Your username / hostname may be known to others, so you cannot copy and use them as your own. On the other hand, your username / hostname might be too weird or too bad or contains offensive characters so you don’t want others to view them. In such cases, there is a little tip that can help you hide username @ localhost in the terminal.

Hide “username @ localhost” in terminal

Edit the file “~ / .Bashrc”:

vi ~/.bashrc

Add the following line at the end:

PS1="W> "

: wq, save and close the file.

Then run the following command for the changes to take effect.

source ~/.bashrc

That’s all. Now check your terminal. You won’t see username @ localhost. You will only see the symbol ~>

How to hide or change “username @ localhost” in terminal

Change “username @ localhost:” in terminal

We don’t want to hide username @ localhost. Can we change it to something else? Yes of course! You can change the Bash prompt to something cool and meaningful.

Edit the file ~ / .bashrc:

vi ~/.bashrc

Add the following line at the end:

PS1="destroyer> "

Replace “destroyer” with something else of your choice. : wq to save and exit the file.

Run the following command to update the changes.

source ~/.bashrc

Now the bash tooltip will have the letters destroyer on the line.

destroyer>#

Note: This is bad practice in some cases. For example, if there is another shell, like Zsh, which inherits the current shell, it will cause some problems. Use it only for hiding, or by modifying username @ localhost if you are using one shell. Apart from hiding username @ localhost in the terminal, this advice is useless and can be problematic. Is there any other way?

Want to know another easy way without changing the file ~ / .bashrc? Just create another user account something like user @ example, or admin @ demo… Use these accounts to create tutorials, videos and upload them to your blog or website. Now, you have nothing to worry about your safety.

We hope this helps. If you find our guides helpful, please take the time to share them on social, professional networks so that everyone will benefit from them.

Sidebar