linuxterminalprompt

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.

Thanks


Solution

  • 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.