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

How can I change the hostname that is in the command prompt.

I have

[root@domU-12-31-19-93-37-71 ~]# ls

Can I change to

[root@jasonvaritek ~]# ls
share|improve this question
    
What specific type of unix is this? Is it Linux/BSD or something else? I have seen a few odd-ball unixes that do not have the hostname command. –  Zoredache Mar 14 '11 at 23:46
    
its Amazon Linux which I believe is most like RHEL6 –  JiminyCricket Mar 14 '11 at 23:51

1 Answer 1

The easiest way is to change the hostname for the machine permanently, rather than on the CLI with the 'hostname' command. You can make this change in /etc/sysconfig/network on a RHEL/Centos/Fedora machine at least. Once you reboot the machine the hostname in the command prompt should reflect your change.

You can also make the change through the PS1 variable if using a bash shell. For example, running

echo $PS1

Will show something along the lines of "[\u@\h \W]\$". Here, \u is the username, \h is the hostname and \w displays the basename of the current working directory, with $HOME abbreviated with a tilde.

To change the hostname, you just needto set $PS1 to reflect your value instead of your hostname, like this

PS1="[\u@jasonvaritek \W]\$"

Of course, if you want this change to persist you'll need to set the environment variable in your bash profile settings.

share|improve this answer

Your Answer

 
discard

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.