In order to change your host name you need to edit two files and then reboot the system.
In my examples below I use vi as the editor. If you are not familiar with vi you can replace it with something like gedit (for a GUI editor) or pico (for an easy to use command line editor).
1. Edit the hostname file.
This file contains a single line that includes only the hostname itself and nothing else. Replace the current hostname with the one you'd like.
sudo vi /etc/hostname
2. Now, we need edit the hosts file so that the system can find your new host name. To do that, run the following command.
sudo vi /etc/hosts
Change the hostname on the second line. See the example below.
127.0.0.1 localhost 127.0.1.1 <hostname>
3. Finally, reboot the system with the following command.
sudo shudown -r now