3

I changed the host name and went to make it stick, but my previous solution didn't work. I am using Linux raspberrypi 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017 armv7l GNU/L. Is there a new way to do this (other than reboot)?

pi@raspberrypi:~ $ /etc/init.d/hostname.sh
-bash: /etc/init.d/hostname.sh: No such file or directory
pi@raspberrypi:~ $
  • Use hostnamectl: sudo hostnamectl set-hostname NAME – cylgalad Dec 7 '17 at 8:55
4

hostname.sh has never been the right thing to use. Not only is it one of the van Smoorenburg rc scripts that systemd specifically masks on Debian, but running it was not the way to make a hostname persistent across reboots even with van Smoorenburg rc. It's the script that reads the persistent hostname.

The static hostname, from which the dynamic hostname is initialized during bootstrap, is stored in /etc/hostname on Debian Linux. You can edit that file directly, or use tools such as hostnamectl which use Desktop Bus, a client-server API, and a started-on-demand server program to … write that file for you. ☺

Further reading

  • Wasn't implying persistent across reboots as editing /etc/hostname (and likely /etc/hosts for domain name) does as well. But it will not take affect until the machine is re-boot (or the old /etc/init.d/hostname.sh was executed). – user1032531 Dec 7 '17 at 12:10
  • wiki.debian.org/HowTo/ChangeHostname also describes using invoke-rc.d hostname.sh. – user1032531 Dec 7 '17 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.