Whenever Ubuntu is installed, unless specified by the user, The machine is given a hostname related to the machine. As this contains certain system and user information. Changing the default hostname is a good security practice.
What is a hostname?
A hostname is the name of your computer. It is how other devices across local networks can identify the computer. The hostname is like an internet URL. For example, to access google you would type http://www.google.com as opposed to it’s IP address like http://184.108.40.206/. The same is possible on local networks. Accessing a computer by its hostname rather than it’s local IP address like 192.168.1.100
What information does it give?
Although configurable during installation. When setting up a user account, With the installer recommendation usually produces a hostname of username-pc make/model. Discovery on networks then gives this information out. For example on my custom built desktop the hostname is:
Not too bad, only giving out the username. On my laptop though it’s
From this, you can see the default username and especially in the case of the laptop the model number.
Find your Hostname.
You can find your hostname by opening a terminal and the prompt should read [email protected] If for whatever bizarre reason it doesn’t simply type:
How should you change it?
I would definitely recommend removing any reference to a user name, and any specific model information. Instead look at either a brief description of the PC, its use, or location. Keep it relevant though to find easily on local networks. Especially when there are many devices connected. There are some rules about what you can change the hostname to though:
- The hostname can only contain letters, digits, and the hyphen character, and the period character
- The hostname must begin and end with a letter or number
- The hostname must be between 2 and 63 characters long
Changing the hostname
GUI (Gnome Settings)
Open settings through the status menu (or through the activities menu)
Select Details at the bottom of the list on the right.
Change the entry in the Device Name box.
Through the terminal
Open a terminal through the activities menu (Or Ctrl+T) and enter:
hostnamectl set-hostname <new_hostname>
You will also need to edit the /etc/hosts file with
sudo gedit /etc/hosts
and change the entry from your previous hostname to the new one.
Is it worth it?
If you have been assigned a hostname it’s always worthwhile changing the default hostname. Especially in multi-user network setups. Not only does it remove the username in machines with multiple user profiles, but it also enables the users to find the machine easier on a network. This is especially true if the default hostname is based on the PC model.
Do you have a format you use to label machines in a network? Let us know in the comments below.