Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have changed the hostname and hosts file in /etc, however my bash prompt has not changed, do I need to restart something (like the OS?) for this to take effect?

share|improve this question

migrated from stackoverflow.com Aug 5 '12 at 14:08

This question came from our site for professional and enthusiast programmers.

It depends on your system, but, perhaps, you may want to use the hostname command. You may still need to restart bash, perhaps, or reload it's profile/rc file.

share|improve this answer
Thank You Very Much! – jroberts Apr 18 '12 at 22:28

First of all, changing the hostname in /etc/hosts does not actually change the hostname. To change that temporarily, use the hostname command. Changing it so it is also changed after a reboot, depends on your OS. For Red Hat derived systems, change the HOSTNAME variable in the file /etc/sysconfig/network.

Changing the hostname displayed in your bash prompt depends on how your bash prompt is set up. If it reads the hostname on each prompt, it will change the next time you press ENTER. If it only reads the hostname during initialization and stores that in a variable which is then displayed in the prompt, then you

share|improve this answer

I believe the hostname is stored in an enviroment variable (called HOSTNAME :<). It is probably not updated dynamically.However,it is supposed to update when restarting bash.
You can also check whether the hostname was actually changed by executing the program hostname (Oh really?)

share|improve this answer

Your Answer


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