How to change hostname in raspberry pi ? ( screenshots included)

How to change hostname in raspberry pi

What is Hostname?

A hostname is the label  assigned to a device  on a network and is used to distinguish one device from another on a specific network or over the internet.
If you are using ssh in your raspberry pi,then the concept of hostname will help you to make it little more easier.
Since IP address can change ,it is not a good idea to  use IP address for ssh configuration . So here  i would like to explain  " how to change the hostname in raspberry pi

1.Login into raspberry pi terminal

2.Use hostname command

This will show you the current host name of your pi 
(if you are using rasbian distribution from raspberrypi.org  then the default hostname will be "raspberrypi.local" )

3.Use sudo hostname command

  Then change the hostname in this file  ( using " mypi " as new hostname)


How to change hostname in raspberry pi

4.Next use sudo nano /etc/hosts and change the hostname in that file


change hostname using termina


5.Next use sudo nano /etc/hostname and change the host name in this file 



Edit raspberry pi hostname



6.Lastly use the reboot command (or sudo reboot) to restart the raspberrypi ,
and ssh back in using this new hostname 

  sudo ssh <username>@hostname.local


ssh using hostname in rpi