Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

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

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

3 Answers

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
add comment

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
add comment

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
add comment

Your Answer

 
discard

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