Linux: changing hostname on the fly

To change hostname on a machine quickly


echo 'hostname' > /proc/sys/kernel/hostname

logout and log to see the changes.

The proc dir is a pseudo file system. To do it permanently, you need to change /etc/sysconfig/network and /etc/hosts

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Sitecritic.net Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.