Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 10 down vote accepted

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>
share|improve this answer
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
Ah, found it. Needed to update /etc/hosts as well. – Patrick Apr 19 '14 at 23:36
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"
share|improve this answer
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
@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.


share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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