1. Edit the /etc/hosts
file
sudo nano /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 raspberrypi
2. Change last line to the new hostname
127.0.0.1 raspi
3. Also edit and change the hostname file
sudo nano /etc/hostname
4. Commit the changes
sudo /etc/init.d/hostname.sh
sudo reboot
You also can change the hostname using raspi-config
sudo raspi-config
Or using Adafruit Pi Finder
sudo nano /boot/[hostname].txt