Logo

How to Set or Change Hostname on Ubuntu 24.04

Mar 14, 2024

To change the hostname on Ubuntu 24.04, follow the steps below:

Step 1 : Check the current hostname using the following command:

hostname

Step 2 : Set the new hostname using the following command:

sudo hostnamectl set-hostname server-01

Step 3 : Verify the change by checking the contents of the hostname file:

cat /etc/hostname

Step 4 : Open the hosts file to update the hostname:

sudo nano /etc/hosts

Step 5 : Replace the old hostname with the new one in the hosts file.

Step 6 : Reboot your system for the changes to take effect:

sudo reboot

Congratulations! You have successfully set or changed the hostname on your Ubuntu 24.04 system.

Recommended