less than 1 minute read

do the following:

  1. sudo vim /etc/hosts
    1. change last line: 127.0.1.1 XYZ
    2. where XYZ should be the new name you want
  2. sudo vim /etc/hostname
    1. replace the name in this file with the new name
  3. sudo /etc/init.d/hostname.sh
  4. sudo reboot

src: howtogeek.com