To change the hostname on Ubuntu 24.04, follow the steps below:
Step 1 : Check the current hostname using the following command:
Step 2 : Set the new hostname using the following command:
Step 3 : Verify the change by checking the contents of the hostname file:
Step 4 : Open the hosts file to update the hostname:
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:
Congratulations! You have successfully set or changed the hostname on your Ubuntu 24.04 system.