3

When I installed Ubuntu I named my computer "test"

after the installation was finished, I renamed the hostname to somewhat nicer:

sudo hostname silversurfer

And I added the hostname to /etc/hosts

But still even after a reboot, in syslog all messages are preceeded by "test":

tail -f /var/log/syslog
Feb 24 04:51:28 test ntpd[4598]: peers refreshed
Feb 24 04:51:28 test ntpd[4598]: Listening on routing socket on fd #24 for interface updates
...

My /etc/hosts/ looks like this:

127.0.0.1   localhost
127.0.1.1   test silversurfer

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
rubo77
  • 31,573
  • 49
  • 159
  • 281
  • possible duplicate of [How do I change the hostname without a restart?](http://askubuntu.com/questions/87665/how-do-i-change-the-hostname-without-a-restart) – jobin Feb 24 '14 at 03:59
  • it is not a duplicate, I did exactly what that answer suggests, but my syslog still has the old host in it. Even after several reboots! – rubo77 Feb 24 '14 at 04:02
  • Did you restart networking? – jobin Feb 24 '14 at 04:03
  • sure, I rebooted! that will restart everything won't it? – rubo77 Feb 24 '14 at 04:05

2 Answers2

3

I found out:

the first hostname for 127.0.1.1 in /etc/hosts is mentioned in syslog, so you have to change:

127.0.0.1   localhost
127.0.1.1   silversurfer test

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
...
rubo77
  • 31,573
  • 49
  • 159
  • 281
1

To change the hostname Permanently Edit the file /etc/hosts

# vi /etc/hosts

127.0.0.1       localhost
192.168.1.100    sambafileserver    samba

Setting up Hostname in /etc/hostname file

# echo "Your Hostname Herer" > /etc/hostname
# hostname -F /etc/hostname

Example:

# echo "sambafileserver" > /etc/hostname
# hostname -F /etc/hostname

Then Restart the Desktop or Server.

Logs file which Created Before hostname change will be in test.

Babin Lonston
  • 6,186
  • 1
  • 23
  • 24