Currently my dhcp-log displays my Raspberry Pi with the name xbmc-e0cb. Can I change this to a more sensible name?
Asked
Active
Viewed 1.1k times
10
Peter Mortensen
- 2,004
- 2
- 15
- 18
towi
- 545
- 2
- 5
- 8
4 Answers
11
Update the host name in the following files
/etc/hostname
/etc/hosts
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>
Praetorian
- 103
- 4
René Wolferink
- 273
- 3
- 10
3
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"
2
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.
hth
ortang
- 496
- 3
- 5
1
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.
patricktokeeffe
- 557
- 2
- 5
- 11