What's in a Raspberry Pi name? How to rename your RPi under Raspbian
A common task after setting up Raspbian-based Raspberry Pi systems is to change the machine’s name (the hostname) because it will, by default, be set to raspberrypi. While this may not be an issue if you have only one RPi on your network, for anyone developing Internet of Things (IoT) systems where there are multiple RPi’s, it would obviously be desirable to give them more useful hostnames.
You can change the hostname temporarily using the hostname command (note that you must use sudo otherwise the command will fail) but, once you reboot, the name will revert to what it was previously set to and what we usually want is to change the hostname permanently. There are a number of ways this can be achieved including using the hostname command in a shell script at startup which could perhaps be useful if you need a dynamically defined hostname but the method most often cited is by editing the hosts file, thusly:
To read this article in full or to leave a comment, please click here
