Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Howto: Change the hostname of a system SAFELY

  1. #11
    Join Date
    Nov 2008
    Location
    Powell River, BC, Canada
    Beans
    208

    Re: Howto: Change the hostname of a system SAFELY

    Thanks sammydee. But there is an easier, safer and faster way to do this.

    Using Ubuntu 8.04 LTS (Desktop edition).

    Steps
    * Navigate to System > Administration > Network
    * Select the General tab.
    * You might have to click on Unlock button.
    * Enter the new name of your computer in the Host name field.
    * Click Close button.
    * Close all open applications and reboot.

    This will automatically change all settings related to hostname (computer name). Including /etc/hosts and /etc/hostname
    Last edited by Francewhoa; March 12th, 2010 at 06:18 PM.

  2. #12
    Join Date
    Nov 2009
    Beans
    48

    Re: Howto: Change the hostname of a system SAFELY

    Hi.

    How would you do that in Ubuntu 9.4. There's isn't 'Network' there's 'Network Tools' and there's no 'General' tab under that.

    Under Ubuntu Help & Support on the computer it has it under 'Network Settings' but that isn't there either.

    I've got - Network: Tools; Connections; Proxy, and none of them have a 'General' tab.

    I really want to change my computer's name from the one that it is now - the place I bought it - came like that.

    Thanks.

  3. #13
    Join Date
    Jan 2006
    Location
    Bristol, UK
    Beans
    275
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Howto: Change the hostname of a system SAFELY

    Quote Originally Posted by dbch View Post
    Hi.

    How would you do that in Ubuntu 9.4. There's isn't 'Network' there's 'Network Tools' and there's no 'General' tab under that.

    Under Ubuntu Help & Support on the computer it has it under 'Network Settings' but that isn't there either.

    I've got - Network: Tools; Connections; Proxy, and none of them have a 'General' tab.

    I really want to change my computer's name from the one that it is now - the place I bought it - came like that.

    Thanks.
    Hey, just follow the instructions in the original post. You don't need to rely on the graphical way for that to work.

  4. #14
    Join Date
    Feb 2007
    Location
    Kraftwerk-City
    Beans
    19
    Distro
    Ubuntu

    Re: Howto: Change the hostname of a system SAFELY

    Quote Originally Posted by sammydee View Post
    Code:
    127.0.0.1       localhost
    127.0.1.1       old_hostname
    FYI, this is mainly for servers or machines with "hardcoded" IP's and according DNS entries, but still might be of interest to some ppl.

    Code:
    root@tuvok:/home# cat /etc/hosts
    127.0.0.1       localhost
    213.239.x.x tuvok q3.xxxxx.de tuvok.xxxxx.de
    Cheers,
    s1mmel

  5. #15
    Join Date
    May 2008
    Beans
    7
    Distro
    Ubuntu 10.04 Lucid Lynx

    Smile Re: Howto: Change the hostname of a system SAFELY

    Hey sammydee. Thanks for the simple & clear instructions. Worked like a charm on my laptop running ubuntu 10.04.

    And yes, I did make backups .

  6. #16
    Join Date
    Apr 2007
    Location
    Texas, USA
    Beans
    809
    Distro
    Kubuntu 12.10 Quantal Quetzal

    Re: Howto: Change the hostname of a system SAFELY

    Great tip man!

    Thanks for the help
    Laptop: [AMD Vision A4-3300M | 8GB RAM | ATI Radeon 6480G | Ubuntu 12.04 64-bit]

    Studio Box: [AMD Athlon 64 X2 5000+ | 4GB RAM | Nvidia 210 | M-Audio FastTrackPro | KXStudio 11.04 64-bit | 2.6.31-rt14-custom | KDE 4.6.5]

  7. #17
    Join Date
    Aug 2008
    Beans
    573

    Re: Howto: Change the hostname of a system SAFELY

    Quote Originally Posted by Onopoc View Post
    Thanks sammydee. But there is an easier, safer and faster way to do this.

    Using Ubuntu 8.04 LTS (Desktop edition).

    Steps
    * Navigate to System > Administration > Network
    * Select the General tab.
    * You might have to click on Unlock button.
    * Enter the new name of your computer in the Host name field.
    * Click Close button.
    * Close all open applications and reboot.

    This will automatically change all settings related to hostname (computer name). Including /etc/hosts and /etc/hostname

    In case you don't have this you need to install Network tool. So pop open a terminal and type:
    Code:
    sudo apt-get install gnome-network-admin
    You could also use Synaptic if you prefer to use a gui and search for network-admin.

  8. #18
    Join Date
    Mar 2010
    Location
    Freedom 3
    Beans
    379
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Howto: Change the hostname of a system SAFELY

    Hi,

    Nice and brief, easy to follow howto. And it definitely works as is on a usual Ubuntu installation. But it may break some packages or even the system itself if /etc/sudoers has been configured with more restrictive than the defaults settings, say like the ones in this howto of the month.

    So, I would propose to add the following two steps in the process, in order to extend the domain of successful application of this howto and save the need to restore to our previous settings:

    -----------

    a. Just after the cp commands:

    If you are certain that you never changed the configuration of sudo, you may skip this step.

    Use
    Code:
    visudo
    to inspect the contents of /etc/sudoers. Watch for any lines that do not start with the comment character (#) and contain the old_hostname.

    If you find such line(s), change the hostname in those lines to the new one and save your changes. Else close the editor without saving any changes.

    b. Just before rebooting:

    Inspect the configuration files in your system for places that your hostname is used. Use the `find' command to grep all files inside /etc for instances of your old_hostname.

    Explanation of arguments:
    -O2 : a speed optimisation flag
    -type f : only look for files
    -name '*[!~]' : do not consider backups (that end in ~)
    -exec grep : execute the grep command on each file's contents
    -Hn -C0 : show filename and line number and do not print context lines (to make the list short)
    old_hostname : replace it with your old hostname
    '{}' ';' : enter them as is, they mean the found file and the end of find command
    | less : pipe the output to less in order to browse it all if it is too long
    Code:
    find -O2 /etc -type f -name '*[!~]' -exec grep -Hn -C0 old_hostname '{}' ';' | less
    Note down the files that need editing.

    Alternatively, you can slightly modify the above command to also write the output to a file which you will then open with your graphical viewer/editor of choice (replace <filename> with your desired path to the file):

    Explanation of (additional) arguments:
    | tee <filename> : pipe output to `tee' first, to duplicate it in <filename>; the pipe following sends it also to less.
    Code:
    find -O2 /etc -type f -name '*[!~]' -exec grep -Hn -C0 old_hostname '{}' ';' | tee <filename> | less
    Now use your favorite editor to open all files that were found to contain references to old_hostname and change all instances of old_hostname to the new_hostname.

    -----------

    For example, in my system the following files (apart /etc/hosts and /etc/hostname) would also have needed editing:

    /etc/sudoers
    /etc/postfix/main.cf
    /etc/inetd.conf
    /etc/apache2/sites-available/default-ssl
    /etc/apache2/sites-available/default
    /etc/gtags/htmake.conf
    /etc/psad/psad.conf
    To suppress free speech is a double wrong. It violates the rights of the hearer as well as those of the speaker.
    Free Software - Free Society | The GNU Project | FSF | ESP

  9. #19
    Join Date
    Aug 2008
    Beans
    573

    Re: Howto: Change the hostname of a system SAFELY

    Whats sudoers and how does it effect changing your hostname? I can't find a good explanation on what it is.

  10. #20
    Join Date
    Mar 2010
    Location
    Freedom 3
    Beans
    379
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Howto: Change the hostname of a system SAFELY

    Quote Originally Posted by COKEDUDE View Post
    Whats sudoers and how does it effect changing your hostname? I can't find a good explanation on what it is.
    It may have an effect, if you select to grant permissions based on hostname (to narrow down the potential or a remote attack). This is something that is suggested as part of hardening a system. The link to the sudoers configuration howto in my previous post is quite explanatory; you can also try `man sudo' and `man sudoers' inside a terminal window.
    To suppress free speech is a double wrong. It violates the rights of the hearer as well as those of the speaker.
    Free Software - Free Society | The GNU Project | FSF | ESP

Page 2 of 3 FirstFirst 123 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
  •