How To

How to Perform Ubuntu Hostname Change Without Rebooting

An Ubuntu Hostname Change is a common administrative task used to rename Linux servers, desktops, and virtual machines. The hostname acts as the system’s network identity, helping devices communicate properly across local and cloud environments.

Whether you manage a home server or enterprise infrastructure, assigning a clear and unique hostname makes system administration easier. Modern Ubuntu releases allow hostname changes instantly without restarting the machine.

This guide explains how to update the hostname using terminal commands and graphical settings safely.

Why Ubuntu Hostname Change Is Important

Every Linux machine should have a unique hostname. Duplicate names on the same network can create connection issues, DNS conflicts, and management confusion.

System administrators often rename machines after deployment to match server roles, departments, or production environments. For example, names like web-server01 or db-node02 make infrastructure easier to organize.

Before changing anything, check the current hostname:

hostnamectl

The command displays the active static hostname, operating system version, kernel details, and additional system information.

Ubuntu Hostname Change Using hostnamectl

The easiest way to rename a Linux system is with the hostnamectl command. This tool is included in modern Ubuntu versions and updates the hostname instantly.

To change the hostname, run:

sudo hostnamectl set-hostname server.example.com

Replace server.example.com with your preferred hostname.

You can also configure a more readable display name called the pretty hostname:

sudo hostnamectl set-hostname "Development Server" --pretty

After making changes, verify the new hostname:

hostnamectl

The updated hostname should appear immediately without requiring a reboot.

Ubuntu Hostname Change in Desktop Settings

Ubuntu Desktop users can also rename their systems through the graphical interface.

Open Settings, navigate to System, and select About. In the Device Name section, enter the new hostname and apply the changes.

This method updates both the system hostname and the visible device label shown across the desktop environment.

For users unfamiliar with terminal commands, the GUI option offers a faster and more user-friendly approach.

Update the Hosts File After Hostname Changes

After performing an Ubuntu Hostname Change, it is important to update the /etc/hosts file. This file maps local IP addresses to hostnames for internal networking.

Open the file:

sudo nano /etc/hosts

Replace the old hostname with the new one:

127.0.0.1   localhost127.0.0.1   server.example.com

Save the file and exit the editor.

If this step is skipped, some local applications may continue using the old hostname.

Cloud Server Hostname Troubleshooting

Cloud-based Ubuntu systems may automatically restore old hostnames during reboot because of the cloud-init service.

To keep the hostname permanent, edit the cloud configuration file:

sudo nano /etc/cloud/cloud.cfg

Find the following line and set it to true:

preserve_hostname: true

This prevents cloud-init from overwriting your manually configured hostname after restart.

Conclusion

Performing an Ubuntu Hostname Change is a simple but essential Linux administration task. Whether you use hostnamectl, GNOME Settings, or cloud server configurations, Ubuntu makes hostname management straightforward and fast.

By updating the hostname correctly and adjusting the hosts file when needed, you can maintain cleaner network organization and avoid connectivity issues across Linux environments.

Cyber Defence

Recent Posts

Bash Scripting Best Practices Every Beginner Should Know

Introduction Bash scripting is a powerful way to automate Linux tasks, but writing a script…

2 days ago

How To Create A Self-Signed SSL Certificate Using Bash And OpenSSL

Introduction A self-signed SSL certificate is a certificate that is created and signed by the…

2 days ago

How To Debug Bash Scripts Using bash -x And set Commands

Introduction Debugging is an important part of Bash scripting. When a script does not work…

2 days ago

How To Use Cron Jobs With Bash Scripts For Automation

Introduction Cron jobs are used in Linux to run commands or Bash scripts automatically at…

2 days ago

How To Use Pipes In Bash Scripts For Command Chaining

Introduction Pipes are an important feature in Linux and Bash scripting. A pipe allows you…

2 days ago

How To Use grep, awk, And sed In Bash Scripts

Introduction The grep, awk, and sed commands are powerful text-processing tools in Linux. They are…

2 days ago