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

git fetch vs git pull: How They Work and When to Use Each

Both git fetch and git pull talk to a remote repository, but they do very different things to your…

3 days ago

git cherry-pick Command: Apply Commits from Another Branch

Sometimes the change you need already exists, just on the wrong branch. A hotfix lands…

3 days ago

Best Email APIs for Secure Business Email: Why Developers Are Moving Beyond SMTP

Email is still one of the most important communication channels inside modern applications. Password resets,…

3 days ago

Nginx Commands in Linux: Start, Stop, Reload, Test, and Log

Nginx is a high-performance web server and reverse proxy trusted by some of the largest…

6 days ago

ufw Command in Linux: Manage Firewall Rules with Examples

ufw (Uncomplicated Firewall) sits on top of iptables (or nftables on newer systems) and replaces…

6 days ago

who Command in Linux: Show All Logged-In Users and Sessions

When you share a server with a team or investigate unexpected activity, the first question…

6 days ago