From charlesreid1

To change the hostname of a Linux system:

$ hostname newname

Pretty simple.

Note that this information should also be updated in /etc/hostnames. (I think.)

Once you run the above command, log out and log back in for it to take effect.

Also see: https://github.com/charlesreid1/dotfiles/blob/master/set_machine_name.sh