Currently my dhcp-log displays my Raspberry Pi with the name xbmc-e0cb. Can I change this to a more sensible name?


Update the host name in the following files


Change the name, and it will change on network-restart (or full reboot, of course).

Updating /etc/hosts is necessary to avoid the following error

sudo: unable to resolve host <new-hostname>
  • 2
    Thanks. I found out that my dhcp would need to be reconfigured if I wanted the Pi also be getting this as a name in my net. – towi Dec 10 '12 at 10:58
  • When I changed the file's contents, and attempted to overwrite the file, I was told that the Pi Can't open file to write. How can I fix this? – xxmbabanexx Mar 25 '13 at 18:22
  • Did you edit it as root or as normal user? Try putting sudo in front of your edit-command. – René Wolferink Mar 26 '13 at 8:53
  • 2
    Ah, found it. Needed to update /etc/hosts as well. – Patrick Apr 19 '14 at 23:36
  • 1
    No matter what I do, my hostname won't change: /etc/hostname = raspbmc /etc/hosts = raspbmc $ hostname raspbmc But my router still picks it up as xbmc-7164. Any ideas? – andersonvom Oct 4 '14 at 22:17

I did this, adapted from http://forum.stmlabs.com/showthread.php?tid=7180

sudo nano /scripts/nm_util.py

Almost at the bottom of the file, uid is set. Comment out all of the if clause, and change it to

uid = "MyHostname"
  • This doesn't tally with my file. I have uuid = params['nm.uuid'] at the start of def deactivate_connection. Is that what you refer to? – geotheory Sep 6 '14 at 12:29
  • 1
    @geotheory: he refers to the lines near "uid = "xbmc-"+mac_list[4].lower()+mac_list[5].lower()", but it is a confusing answer (for instance, "almost at the bottom of the file" is actually only 80% down in the file). – Peter Mortensen Jan 4 '15 at 16:33

Additionally you can change the hostname on the fly by issuing the commang sysctl kernel.hostname=NEW_HOSTNAME. But that is no permanent solution. @René Wolferink already posted the only permanent way.


  • Nonetheless, thank you for completing the picture and not requiring a reboot. Useful tip way beyond just raspbmc. – Fergal Moran Sep 21 '13 at 22:48

With the introduction of systemd (Raspbian Jessie and newer), the prescribed method is finally a single command (reference):

sudo hostnamectl set-hostname <mymachine>

Changes take effect immediately and persist after reboot.

  • 1
    I may have posted too soon... this seems to leave /etc/hosts in a dismal state – patricktokeeffe Dec 15 '16 at 4:40

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.