Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 424
user3578858 Avatar asked May 08 '14 05:05

user3578858


2 Answers

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.

like image 180
jobin Avatar answered Oct 19 '22 03:10

jobin


If you frequently want to hide the terminal info temporarily, you can create a bash alias for this in the .bashrc:

# anon - anonymous
alias anon='clear && export PS1="$ "'

And use the alias instead:

$ anon

To get back the terminal info, do (you can create an alias for this as well):

exec "$BASH"
like image 30
Wenfang Du Avatar answered Oct 19 '22 01:10

Wenfang Du