Changing the name of your Pi is a pretty straightforward task.
There are just two files that need to be changed to do this.
First, edit the file /etc/hostname. You can do this by opening a Terminal window and typing the following command:
$ sudo nano /etc/hostname
Replace “raspberrypi” with a name of your choice. This should be one word, with no punctuation or unusual characters (including the _ character.)
Now open the file /etc/hosts in an editor using the command
$ sudo nano /etc/hosts
The file will look something like this:
::1 localhost ip6-localhost ip6-loopback
Replace the text at the end that uses the existing name (“raspberrypi”) to the new name that you desire to be used.
Restart the Raspberry Pi, and you should see that the name has changed when you view it on the network from another computer or using an IP scanner