I update my BeagleBone images very frequently. As soon as you have more than one beagle running around your house, keeping track of them takes some effort. I like to have unique hostnames set for each device so that I can ssh into the unique device. I also put a little sticker on each one to remind me of the hostname.
Anyway, it’s pretty easy to change the hostname on Debian. To do it properly you need to edit two files,
/etc/hostname. It’s an annoying little task that I do often enough I finally decided to script it. I should start making a collection of these scripts as I perform the same tasks each time, but we have to start somewhere.
#!/bin/bash if [[ "$#" -ne 1 ]]; then echo "$0 usage: newhostname (run as root)" exit 1 fi name=$(hostname) hostname $1 sed -i "s/$name/$1/" /etc/hosts
Also available via
wget https://gist.githubusercontent.com/jbdatko/d7fd5f4232db99f85e00/raw/636dd36cf34069489cd3988de7381d41c7595469/changehostname.sh chmod +x changehostname.sh