Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's not a common scenario, but I find myself accidentally inserting commands into the wrong terminal. I haven't damaged anything important yet; So before I do, what are some of the best ways to differentiate between a local and remote terminal session?

share|improve this question

closed as primarily opinion-based by Jim B, Jenny D, Massimo, Hyppy, mdpc May 8 '15 at 0:44

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 9 down vote accepted

The two main ways to do this are to change your PS1 variable so it contains the host name, and to use different colour schemes on your terminal app for different hosts. You could also use separate colour schemes for root shells.

share|improve this answer
Changing the color of the prompt is great. My prompt is user@host, where normal users are green, and root is red. Host is a different color for each host, so it's easier to tell at a glance which system I'm in and if I'm root. – Mnebuerquo May 13 '10 at 18:45

I always have user and host name in my shell prompt

share|improve this answer

Just to follow up on the previous answers, edit your $HOME/.bash_profile to set PS1 upon login.

PS1='\h [!]: '

The above setting will display the host name of the system plus the history number of the current command.

share|improve this answer

My PS1 has a blue background on (mostly) client machines and red on the servers.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.