Putty title changes after login

21

8

I am connecting with putty to a stock Ubuntu machine hosted at EC2, and notice the following:

When I connect, the title of the putty window appears at first as the hostname I enter (e.g. "myhostname.com"). After it's connected, the hostname changes to a different string - user@domU-12-31-20-0a-81-AB: ~ (different on each machine).

This look like an ethernet address of sort, I'm not sure. It's really annoying because once I open 2-3 putty consoles I can't remember which is which.

Is it possible a ~/.bashrc script run from the machine itself changes the putty title? Somewhere else I should look into?

Update:

I forgot to mention this ... but I have tried this and the title I set up in the connection is shown briefly when connecting, but then overriden just like the default hostname title.

ripper234

Posted 2012-11-26T17:51:32.903

Reputation: 9 293

1Deleted my answer, please update with that info :D – nerdwaller – 2012-11-26T18:31:54.990

Answers

9

It's most likely updated by your shell prompt ($PS1 in ~/.bashrc or the system-wide /etc/bash.bashrc). Look for \e]2; or \033]2; or a similar escape sequence.

Your given example looks like the usual "<user>@<host>:<path>" template, in which domU-12-31-20-0a-81-AB is the server's hostname as currently configured in the kernel. Most likely, it was assigned by an automated Xen domU creation tool based on your virtual server's Ethernet address.

You can change the current hostname by using hostname newname. To make it persist across reboots, look around in /etc – on every reboot, the hostname is read from the file /etc/hostname (other distributions may use /etc/sysconfig/hostname or similar).

user1686

Posted 2012-11-26T17:51:32.903

Reputation: 283 655

Check also $PROMPT_COMMAND – Cheekysoft – 2019-10-18T13:47:50.673

This is all useful information, for changing hostname and prompt, but it seems overkill to change your hostname just to achieve the effect of updating PuTTY's window title ... and it won't work if you're using tmux or something, which will update the window title with the title of the tmux window / "tab" you are in. See @Michael Terry's answer below to change your PuTTY settings, that's what worked for me. – Aaron Wallentine – 2019-11-05T16:18:55.213

@ripper234 Please change the Accepted answer to the question below this one!! – Mike Q – 2019-11-12T19:47:57.880

1It is my shell's prompt - but when I edit it later on using PS1=myprompt it doesn't stick. It seems editing the prompt inside .bashrc affects the putty title. – ripper234 – 2012-11-26T20:34:08.123

58

The easier answer to this question is two configuration changes in your Putty preferences for the session(s):

  1. In Window -> Behaviour set your desired Window title.

  2. In Terminal -> Features check Disable remote-controlled window title changing.

Michael Terry

Posted 2012-11-26T17:51:32.903

Reputation: 681

10Should have been the accepted answer. – T.Rob – 2016-09-05T17:48:10.767

2Step 2 was exactly what I needed, way better than editing all the bashrc files out there – redDevil – 2017-04-27T12:36:12.280

2

An exert from the /etc/bash.bashrc file is to run the following line to fix your title back to the default:

echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"

Canadian Luke

Posted 2012-11-26T17:51:32.903

Reputation: 22 162

this does not work when using tmux or screen, why? – AK_ – 2018-06-07T18:56:06.890

Not sure, I haven't used tmux, and I don't do much in screen... I'll have to research more – Canadian Luke – 2018-06-07T19:26:42.880

2

You can change the title in putty (under linux) with this command:

PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'

in this case, it will display your USER name, your HOSTNAME and it wil Print out your current Working Directory

or you can do this, with a string of your choosing:

xterm -T "Title of My xterm" -n "Title when minimized"

pee

Posted 2012-11-26T17:51:32.903

Reputation: 21

1

For CentOS and RedHat Linux you can create an empty file:

touch /etc/sysconfig/bash-prompt-xterm

And change its permissions with:

chmod 555 /etc/sysconfig/bash-prompt-xterm

Then /ect/bashrc won't change your PuTTY title, which you can set in PuTTY's settings:

Window -> Behaviour -> Window title

Alexander Farber

Posted 2012-11-26T17:51:32.903

Reputation: 233

1

Yet another way, and to piggy-back on @Michael Terry's answer:

If you've already opened your session and don't want to close it - In Windows you can access the appropriate Putty configuration options by right-clicking the window title bar and select "Change Settings...". Keeping in mind changes here will not be saved once the session is closed.

sonofanickel

Posted 2012-11-26T17:51:32.903

Reputation: 31

Yes ... But you can save them if you want to, by going to "Session" in there, and selecting the current session, and clicking "Save". – Aaron Wallentine – 2019-11-05T16:21:22.260

1

Nothing new to what grawity already said but a lot more detailed/mind-blowing article here: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/index.html

Relevant section for title manipulation is: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/xterm-title-bar-manipulations.html

Kashyap

Posted 2012-11-26T17:51:32.903

Reputation: 101

0

If using MTpuTTy (useful for multiple parallel Putty sessions), use

Tools > Settings > General > Tab name > Show Display name

.

Ashutosh Singh

Posted 2012-11-26T17:51:32.903

Reputation: 1