How to hide the hostname on the terminal on linux?


Is there a way I can hide the hostname on the terminal without updating the /etc/hosts or related files.

Generally we see the server details on screen as below

[root@ServernamE /]#

So, I don’t want the hostname = ServernamE to be displayed on terminal. The reason for doing this is, I will be recording a web session. I know that I can morph the desired part but that is time consuming and depend on other softwares.



If you want a temporary solution(since you are talking about a screencast), you can set your PS1 variable to change the prompt.

For example, if you want your prompt to be:


Then set your PS1 variable as follows on the terminal:

export PS1='$ '

Likewise, you can have it to whatever you want the prompt to look like. If you want the path to be displayed, set it as:

export PS1='\w '

For a permanent solution, you can set this in your shell configuration script, which is your ~/.bashrc file in case you have bash as your shell.

Answered By – jobin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published