To change the hostname on Ubuntu 23.04, follow these steps:
Step 1 : Start by checking the current hostname using the command:
Step 2 : Set the new hostname using the following command:
Step 3 : Verify the change by checking the contents of the /etc/hostname
file:
Step 4 : Open the /etc/hosts
file to update the hostname:
In the file, locate the line with the old hostname and replace it with the new one (server-01
in this example).
Step 5 : Reboot your system to apply the changes:
Congratulations! You have successfully set or changed the hostname on your Ubuntu 23.04 system.