edoc Knowledge Base
Breadcrumbs

How do I change the host name of an Ubuntu Linux server?

Component

edoc platform - Ubuntu

Version

16.04 LTS - 20.04 LTS

Created on

Last modified on

No Workflow Applied

Review status

No Workflow Applied

KB article number

316178508

Summary

You have an existing Ubuntu system and would like to persistently change the host name of the system.

Find out how to update the host name in this KB article.

Important requirements

  • You need administrative access to the edoc platform server console.

  • You will need knowledge of a Linux editor such as vim or nano.

  • The server needs to be restarted, so plan the restart with everyone involved to reduce the time of potential software failures.

Solution

To permanently change the host name in an Ubuntu Linux server, you must observe 4 aspects:

  1. Use a text editor to change the entry for IP 127.0.1.1 in the /etc/hosts file.

    # Replace row 127.0.1.1 by 
    127.0.1.1 <fqdn> <hostname>
    # Example
    127.0.1.1 s150.edoc.local s150
    
  2. Update the host name in the /etc/hostname file using a text editor.

  3. Specify the host name with the command sudo hostname -F /etc/hostname.

  4. Restart the server with the command sudo reboot.