Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an ec2 instance. When I log in, it will prompt this:

[ec2-user@ip-10-128-80-10 ~]$ 

I want to rewrite the ip-10-128-80-10 to some nickname, such as us1, us2, us3.

[ec2-user@us1 ~]$ 

How to set it ?

share|improve this question

2 Answers 2

up vote 11 down vote accepted

That's the system's hostname, which you can set in /etc/hostname.

Next, execute this as root

$ service hostname restart
share|improve this answer
if by chance you want to go beyond just setting the host name, your shell has variables to set it's prompt string template (with the hostname and other things wherever you like, or without them). –  Skaperen Sep 8 '12 at 1:42
It works after rebooting :) –  qrtt1 Sep 8 '12 at 1:43
You didn't have to reboot, but rather could have likely just run $ service hostname restart. –  EEAA Sep 8 '12 at 1:47
Probably only needed a logout/logbackin, or maybe even just "exec ${SHELL} -i". –  Skaperen Sep 8 '12 at 2:13

Note that you don't have to change the hostname if you prefer not to. If you just want to change the prompt, you can set the shell variable PS1. At the moment, it's probably set to something like this:

PS1='[\u@\h \w]\$ '

You can set it to anything you like, e.g.

PS1='\u@test1234 \w\$ '
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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