Results 1 to 8 of 8

Thread: Changing hostname permanently

  1. #1
    Join Date
    Jul 2010
    Beans
    9

    Changing hostname permanently

    Hi,

    I am new to Ubuntu 10.04 and so far I love it!!! I recently created a LiveUSB and I am running Ubuntu from my USB drive with preserve mode.

    I changed the /etc/hostname and /etc/hosts files with my new hostname and everytime I reboot those files are going back to original state and change the hostname back to ubuntu...

    The rest of my installed applications and settings are preserved... Is there a way to permanently change the host name?

    Thanks,
    Sefa

  2. #2
    Join Date
    Jun 2010
    Location
    asoko
    Beans
    834
    Distro
    Ubuntu

    Re: Changing hostname permanently

    try
    Code:
    sudo hostname <newhostname>
    and let us know if that works. I had been about to tell you to edit /etc/hostname and reboot, but it seems youve tried that

  3. #3
    Join Date
    Jul 2010
    Beans
    9

    Re: Changing hostname permanently

    Hi,

    I tried

    Code:
    sudo hostname server1
    after the reboot the hostname is reverted back to ubuntu... Any ideas?

    Thanks,
    Sefa

  4. #4
    wojox is offline I Ubuntu, Therefore, I Am
    Join Date
    Apr 2009
    Beans
    8,628

    Re: Changing hostname permanently

    You need to edit two files with root privileges.

    Code:
    gksudo gedit /etc/hosts
    Code:
    gksudo gedit /etc/hostname

  5. #5
    Join Date
    Jul 2010
    Beans
    9

    Re: Changing hostname permanently

    I did try to edit those two files with root privileges. Any ideas? Have anyone run into the same issue?

  6. #6
    wojox is offline I Ubuntu, Therefore, I Am
    Join Date
    Apr 2009
    Beans
    8,628

    Re: Changing hostname permanently

    Quote Originally Posted by sefa View Post
    I did try to edit those two files with root privileges. Any ideas? Have anyone run into the same issue?
    Edit those two files changing only the hostname and reboot.

  7. #7
    Join Date
    Aug 2008
    Beans
    180
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Changing hostname permanently

    Quote Originally Posted by wojox View Post
    You need to edit two files with root privileges.

    Code:
    gksudo gedit /etc/hosts
    Code:
    gksudo gedit /etc/hostname
    This fixed it for me - thanks...!

  8. #8
    Join Date
    Oct 2009
    Location
    Elgin, IL USA
    Beans
    3,363
    Distro
    Ubuntu 16.10 Yakkety Yak

    Re: Changing hostname permanently

    For a live/install iso the system boots before persistent data is mounted, so you might need to copy those /etc/hostname and /etc/hosts to the home directory of the default ubuntu user, edit how you want them, then add these lines to .profile of ubuntu user:

    sudo cp /home/ubuntu/hostname /etc/hostname
    sudo cp /home/ubuntu/hosts /etc/hosts

    Note that files that begin with dot are normally hidden, but you can see them in File Browser by hitting Ctrl+H, or with ls -a in terminal.

Tags for this Thread

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
  •