January 27, 2022
How to change hostname on Ubuntu 18.04 LTS

How To Change Hostname On Ubuntu 18.04

Usually when we install the Ubuntu OS for the first time, by default the name of our hostname is ubuntu. In many cases, we are asked to change the hostname to another name when the system has already running. This article will discuss how to change the hostname on Ubuntu 18.04. Although this change in hostname was made on Ubuntu 18.04, the same way can be done for other versions of Ubuntu as well.

Change Ubuntu Hostname

There are several step must be followed to change the hostname, namely :

  1. Display current hostname
  2. Change the hostname
  3. Edit /etc/hosts file

Display Hostname

The first step is to show the current hostname, by submitting  hostnamectl command line.

ramans@ubuntu:~$ hostnamectl
    Static hostname: ubuntu
          Icon name: computer-vm
            Chassis: vm
         Machine ID: d08900938d9e4b1fb70ae991c8c93f96
            Boot ID: 531596d405fb43b49934d910ac33418d
     Virtualization: vmware
   Operating System: Ubuntu 18.04.3 LTS
             Kernel: Linux 4.15.0-74-generic
       Architecture: x86-64

Change the hostname

The next step is changing the Ubuntu’s hostname to the new one by submitting hostnamectl set-hostname <new_name> command.

ramans@ubuntu:~$ sudo hostnamectl set-hostname otodiginet
 [sudo] password for ramans:
Share this article via :

One thought on “How To Change Hostname On Ubuntu 18.04

Leave a Reply

Your email address will not be published. Required fields are marked *