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

groupdel Command in Linux: Remove a Group and Audit Files

The groupdel command in Linux removes a group from the system. It deletes the group's entry from /etc/group and /etc/gshadow,…

12 hours ago

wc Command in Linux: Count Lines, Words, Characters, and Bytes

The wc command in Linux counts lines, words, characters, and bytes in files or standard input. It…

13 hours ago

top Command in Linux: Monitor Processes and Resource Usage

The top command in Linux provides a real-time view of running processes and system resource usage. From…

13 hours ago

usermod Command in Linux: Modify User Accounts and Groups

The usermod command in Linux modifies existing user account attributes. You can use it to manage group…

13 hours ago

sort Command in Linux: Sort Text, Numbers, Columns, and More

The sort command in Linux reads lines from files or standard input and writes them to standard…

2 days ago

wall Command in Linux: Broadcast Messages to Logged-In Users

The wall command in Linux sends a message to the terminals of all currently logged-in users. The…

2 days ago