Both in the GUI and in the Terminal
How to change hostname on Ubuntu 22.04 LTS / Ubuntu 24.04 LTS
If you need to know the name of your Ubuntu computer, this post will show you several ways to find it. We will also show you how to easily change your hostname. In Ubuntu 17.x, there is a device name and a hostname, which appear to be different. The device name is displayed in the GUI and the hostname is displayed in Terminal. I will show you how to change both.
Your hostname can be found in a few different places. The first place we’ll look is the Terminal window. To open the Terminal window, select Accessories | Terminal from the Applications menu. In newer versions of Ubuntu, such as Ubuntu 17.x, you’ll need to click Activities and then type terminal .
Your hostname is displayed after your username and the "@" symbol in the title bar of the Terminal window. In our case, our hostname is "ubuntu-virtual". This is also displayed in the prompt itself.