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

4 Answers 4


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
    Commented Dec 10, 2012 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? Commented Mar 25, 2013 at 18:22
  • Did you edit it as root or as normal user? Try putting sudo in front of your edit-command. Commented Mar 26, 2013 at 8:53
  • 2
    Ah, found it. Needed to update /etc/hosts as well.
    – Patrick
    Commented Apr 19, 2014 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? Commented Oct 4, 2014 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
    Commented Sep 6, 2014 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). Commented Jan 4, 2015 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. Commented Sep 21, 2013 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 Commented Dec 15, 2016 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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