1

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
2
  • 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, 2011 at 23:46
  • its Amazon Linux which I believe is most like RHEL6 Mar 14, 2011 at 23:51

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .