How to Remove User and Hostname in Terminal Prompt [Quick Geek Tricks]

Spread the love

For Linux (or Mac) users who use the Terminal, you will find that the default prompt will come with the format [username@hostname ~]$. For example, on my Dell laptop the bash prompt will show [damien@damien-dell ~]$, where “damien” is my username, and “damien-dell” is the hostname. Let it be noted that this is only the default settings, and you are free to change it and have it display anything you want, or even remove it altogether.

The following steps show how to do that.

1. In your file manager press Ctrl + H to show hidden files.

2. Open the “.bashrc” file in a text editor.

3. Find the line that starts with PS1=. The complete line should be something like this: PS1='[\u@\h \W]\$ ' where \u represents the username, \h the hostname and \W your location in the file structure.

4. To remove the username and hostname from the prompt, simply remove the \u@\h part so it looks like this: PS1='[\W]\$ '.

5. For pure minimalism, you can remove everything and just leave the prompt sign: PS1='\$ '.

6. Once you are done with the edit, save the file.

Now relaunch your terminal, and the changes will be reflected immediately. If you are not able to restart the terminal because of a running session, type source ~/.bashrc instead.

It’s that simple.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Damien Oh

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.

Comments (2)