Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Hostname in Ubuntu Server 10.04

  1. #1
    Join Date
    May 2010
    Beans
    8
    Distro
    Xubuntu 9.10 Karmic Koala

    Post Hostname in Ubuntu Server 10.04

    First, hello everyone. I'm new to this forum, so if I posted this thread in wrong one, please forgive me.

    I've noticed in Ubuntu Lucid (10.04) when I try to change hostname, it won't change.

    This is how I done it:

    echo server.example.com > /etc/hostname

    nano /etc/hosts

    Then I put this line:

    127.0.1.1 server.example.com

    after

    127.0.0.1 localhost

    Then I rebooted my system. When I tried to run hostname command, I got this:

    root@server:~# hostname
    server.example.com
    root@server:~# hostname -f
    hostname: Name or service not known

    So, if anyone knows how to solve this, I would be very thankful. And sorry for my English, I'm from Bosnia & Herzegovina.

  2. #2
    Join Date
    Aug 2008
    Beans
    13

    Re: Hostname in Ubuntu Server 10.04

    The same thing happened to me after I installed a gui(xfce). Being as unskilled as I am I couldn't figure out how to fix it so I just did a clean install but never put the desktop enviorment on and it worked fine.

    Sorry I wish I could be of more help.

  3. #3
    Join Date
    Jun 2007
    Beans
    Hidden!

    Re: Hostname in Ubuntu Server 10.04

    Quote Originally Posted by Black_Prince View Post
    First, hello everyone. I'm new to this forum, so if I posted this thread in wrong one, please forgive me.

    I've noticed in Ubuntu Lucid (10.04) when I try to change hostname, it won't change.

    This is how I done it:

    echo server.example.com > /etc/hostname

    nano /etc/hosts

    Then I put this line:

    127.0.1.1 server.example.com

    after

    127.0.0.1 localhost

    Then I rebooted my system. When I tried to run hostname command, I got this:

    root@server:~# hostname
    server.example.com
    root@server:~# hostname -f
    hostname: Name or service not known

    So, if anyone knows how to solve this, I would be very thankful. And sorry for my English, I'm from Bosnia & Herzegovina.
    Code:
    npope@ubuntu:~$ sudo vi /etc/hosts
    Replace your current hostname with your new hostname ( i just commented the old one out )
    Code:
    #127.0.1.1      ubuntu      ubuntu
    127.0.1.1       foo     foo
    Change /etc/hostname to new hostname
    Code:
    npope@ubuntu:~$ sudo vi /etc/hostname
    Code:
    foo
    Change hostname
    Code:
    npope@ubuntu:~$ sudo hostname foo
    Log out and back in
    Code:
    npope@foo:~$

  4. #4
    Join Date
    May 2010
    Beans
    8
    Distro
    Xubuntu 9.10 Karmic Koala

    Re: Hostname in Ubuntu Server 10.04

    Quote Originally Posted by ghost_ryder35 View Post
    Code:
    npope@ubuntu:~$ sudo vi /etc/hosts
    Replace your current hostname with your new hostname ( i just commented the old one out )
    Code:
    #127.0.1.1      ubuntu      ubuntu
    127.0.1.1       foo     foo
    Change /etc/hostname to new hostname
    Code:
    npope@ubuntu:~$ sudo vi /etc/hostname
    Code:
    foo
    Change hostname
    Code:
    npope@ubuntu:~$ sudo hostname foo
    Log out and back in
    Code:
    npope@foo:~$
    Well, that was first how I tried it ... As you see in my post, hostname is changed, but when I run command hostname -f it says "hostname: Name or service not known". Command hostname works fine, and I see right hostname after my username, but I still don't get it why I got hostname: Name or service not known even with right entry in /etc/hosts
    Anyways, thanks for your help, I switched back to Ubuntu Server 9.10 for some reasons.
    Last edited by Black_Prince; May 5th, 2010 at 03:27 PM.

  5. #5
    Join Date
    Dec 2008
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Hostname in Ubuntu Server 10.04

    Quote Originally Posted by Black_Prince View Post
    Well, that was first how I tried it ... As you see in my post, hostname is changed, but when I run command hostname -f it says "hostname: Name or service not known". Command hostname works fine, and I see right hostname after my username, but I still don't get it why I got hostname: Name or service not known even with right entry in /etc/hosts
    Anyways, thanks for your help, I switched back to Ubuntu Server 9.10 for some reasons.
    The host name is NOT the FQDN (fully qualified domain name). It is only the host part. So we have a FQDN of: server.example.com -- the host name is: server.

    Using this example the correct hostname command should be:
    Code:
    sudo echo server > /etc/hostname
    I believe this will also work:
    Code:
    sudo hostname server
    Last edited by capscrew; May 5th, 2010 at 05:24 PM.

  6. #6
    Join Date
    May 2010
    Beans
    8
    Distro
    Xubuntu 9.10 Karmic Koala

    Re: Hostname in Ubuntu Server 10.04

    Quote Originally Posted by capscrew View Post
    The host name is NOT the FQDN (fully qualified domain name). It is only the host part. So we have a FQDN of: server.example.com -- the host name is: server.

    Using this example the correct hostname command should be:
    Code:
    sudo echo server > /etc/hostname
    I believe this will also work:
    Code:
    sudo hostname server
    Oh, now I got it... Don't know why I didn't think about it earlier, but in an example that I viewed on howtoforge web site entry for /etc/hosts on Ubuntu Server 10.04 was shown as

    Code:
    127.0.1.1 server1.example.com server1
    So that gave correct hostname resolved. Thanks, you finaly made me understand that example, because it wasn't like in 9.xx or 8.xx versions. Maybe after all I do switch to Ubuntu Server 10.04

  7. #7
    Join Date
    May 2010
    Beans
    8
    Distro
    Xubuntu 9.10 Karmic Koala

    Re: Hostname in Ubuntu Server 10.04

    Quote Originally Posted by capscrew View Post
    The host name is NOT the FQDN (fully qualified domain name). It is only the host part. So we have a FQDN of: server.example.com -- the host name is: server.

    Using this example the correct hostname command should be:
    Code:
    sudo echo server > /etc/hostname
    I believe this will also work:
    Code:
    sudo hostname server
    Oh, now I got it... Don't know why I didn't think about it earlier, but in an example that I viewed on howtoforge web site entry for /etc/hosts on Ubuntu Server 10.04 was shown as

    Code:
    127.0.1.1 server1.example.com server1
    So that gave correct hostname resolved. Thanks, you finaly made me understand that example. Maybe after all I do switch to Ubuntu Server 10.04

  8. #8
    Join Date
    Dec 2008
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Hostname in Ubuntu Server 10.04

    Quote Originally Posted by Black_Prince View Post
    Oh, now I got it... Don't know why I didn't think about it earlier, but in an example that I viewed on howtoforge web site entry for /etc/hosts on Ubuntu Server 10.04 was shown as

    Code:
    127.0.1.1 server1.example.com server1
    So that gave correct hostname resolved. Thanks, you finaly made me understand that example, because it wasn't like in 9.xx or 8.xx versions. Maybe after all I do switch to Ubuntu Server 10.04
    Well almost...

    The /etc/hosts file is where you map the IP address to the hostname. It is NOT where you define the hostname for the OS.

  9. #9
    Join Date
    May 2010
    Beans
    8
    Distro
    Xubuntu 9.10 Karmic Koala

    Re: Hostname in Ubuntu Server 10.04

    Quote Originally Posted by capscrew View Post
    Well almost...

    The /etc/hosts file is where you map the IP address to the hostname. It is NOT where you define the hostname for the OS.
    Well, I said in my first post that my English is bad ... Anyways I got it, thanks.

  10. #10
    Join Date
    Sep 2008
    Beans
    3

    Re: Hostname in Ubuntu Server 10.04

    Just an FYI for the semi-literate:

    I encountered this exact error today & wondered what caused it. A more thorough re-reading of my /etc/hosts file resolved the issue. I had typed "268" instead of "168" as one of the octets in my IP address. Doh!

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •