Say our host is called
alpha
and we want to rename it to
bravo
For a temporary change (does not survive reboot) run in a terminal:
(sudo) hostname bravo
For a permanent change, edit
/etc/hosts
find the entry for
alpha
and change it to
bravo
Next, edit
/etc/hostname
and replace
alpha
with
bravo
NOTE:BSD based systems use /etc/HOSTNAME instead!
Lastly, EITHER restart the networking service in a terminal:
(sudo) service networking restart
and log out / log in again, OR reboot the machine.
NOTE: If the machine cannot be rebooted immediately after the
changes, or you do not want to log out of your session until later,
simply run:
(sudo) hostname bravo