When we connect to aws ec2 instance using ubuntu server, after login I see the following prompt at the bash shell


Is there there a way I can change that text without effect any networking thing in server?

I have searched but didn't find anything that can guide me better in this area. I'd appreciate any help offered.

  • The PS1 variable controls the prompt. See the bash manpage. – jordanm Apr 21 '16 at 23:18
  • Why? What are you accomplishing here? – ceejayoz Apr 21 '16 at 23:43

The key phrase in Google that you want is "how to change ubuntu command prompt", or perhaps "how change bash command prompt". This thread is the second hit for the first query. I'll copy it in here as per SF preferences

To change it for the current terminal instance only Just enter

PS1='\u:\W\$ ' and press enter.

To change it "permanently"

In your ~/.bashrc, find the following section:

if [ "$color_prompt" = yes ]; then
  PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

Remove the @\h, and replace the \w with an uppercase \W, so that it becomes:

if [ "$color_prompt" = yes ]; then
  PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
  PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '
  • i want something like this to show up in my terminal window ubuntu@domain.com – Rohan Zakie Apr 22 '16 at 0:33

You can change the hostname using "hostname" command.

$~ hostname yourdomain.com

Then login back to your server, the prompt name will be changed.

  • I'm not sure this necessarily satisfies the "without effect any networking thing in server" bit. – ceejayoz Apr 21 '16 at 23:44
  • i dont want to break netwrok layer, what i want to achive is , having multiple putty session with each having its own domain name, each domain name links to its own ec2. so for examlple ubuntu@domain1.com$ ubuntu@domain2.com$ – Rohan Zakie Apr 22 '16 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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