How to change your hostname or computer name on Ubuntu Linux
Learn how to easily change your Ubuntu hostname via GUI or terminal.
The first time I set up my Ubuntu Linux OS, I didn’t know they used the computer name entered as the default hostname. So, when I finally got in, you can imagine my shock working on the terminal with this long hostname “HP EliteBook x360 1030 G2” staring at me. I struggled to find my way around it, but that wasn’t till after I’d used that lengthy hostname for a while.
Now, you may not have fallen for the “Ubuntu computer name set as hostname” predicament like I did. Maybe you have a really cool hostname already, but just want to change it for whatever reason, and you’re unsure how. Fortunately, this can be easily done from the Ubuntu GUI or the terminal, whichever method you fancy.
In this guide, we’ll show you both methods step by step, so you can pick whichever feels right for you.
How to change your Ubuntu Hostname using the GUI
Step 1: Go to your App Finder and search for Settings.

Step 2: Scroll down and select System, then click About.

Step 3: You'll see the device name. Clear the input and enter the new name for your device, and hit the Enter button. Then quit the settings app.

How to change your Ubuntu Hostname using the terminal
Step 1 (Optional): Your hostname is saved in the etc directory. To confirm, run "ls /etc -la" to find the hostname.

Step 2 (Optional): Now that we've confirmed we have a hostname folder, to see its information, run "hostnamectl"

Step 3: To change the hostname, run "hostnamectl set-hostname 'preferred-name'". To confirm the change, run the "hostnamectl" command to see your hostname details.
NB: Your terminal will still have the old name until you refresh or close it.

Step 4 (Optional): Update the hostname in the hosts file. This is good because the hosts file maps IP addresses to domain names. To see the details, run "cat /etc/hosts"

- Open the hosts file with the command "sudo nano /etc/hosts." Some people open it with just "nano /etc/hosts," which is fine, but this may be an issue if you don't have write access.

- You'd see that your old hostname is still mapped to your IP address.

- Now just change the hostname and save the file, then exit.

To confirm the change, run the "cat /etc/hosts" command again

Conclusion
And there you have it, changing your hostname in Ubuntu doesn’t have to be a headache. Whether you went the GUI route for its simplicity or embraced the terminal for speed, you’ve now got a system name that makes sense.
Now that your machine has a proper identity, you might even find it easier to manage if you’re working with multiple systems or running servers. A clean, recognizable hostname helps avoid confusion, especially in shared environments or remote setups.
So go ahead, enjoy your newly renamed Ubuntu system. Whether you choose something practical, playful, or just plain cool.
Image Credit: Oyinebiladou Omemu/Techloy.com