Related Items  

Linux and Windows IT Support  

dedicated-technology-experts

Windows, Apple and Linux IT support and services.

For Software and Web Development.

Change hostname in Ubuntu 18

PrintE-mail

ubuntu-logo-sm In Ubuntu 18.04, when you update the /etc/hostname, the name doesn't stay after the reboot. Why that doesn't work anymore is a story for another day. What we are interested in now is changing the hostname to something that survives the reboot. Note that as any other admin command, you either have to run as sudo or root.

To check the current hostname, run the following command:

hostnamectl

It will display, among other things, the current hostname:

Static hostname: terra

To change it, run the following command (where terra2 is the new name):

hostnamectl set-hostname terra2

The command above actually just goes and modifies the /etc/hostname file, but that's not enough to make it survive the reboot. You have to go in and modify a special file, asking it to preserve the settings.

In the file /etc/cloud/cloud.cfg locate preserve_hostname and set it to true from false:

 

preserve_hostname: true

 

After that, reboot the system and your hostname should stick.

Add your comment

Your name:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
yvComment v.1.24.0
   
Copyright © 1999 - 2024 Virtual Helpme | Techical Support and Maintenance | Original Template: Allrounder