Learn how to permanently change the hostname on Ubuntu. Our Server Management Support team is here to help you with your questions and concerns.
How to Permanently Change the Hostname on Ubuntu
Did you know that changing the hostname on your Ubuntu system is as easy as 1-2-3 and can be done without rebooting?
Our experts have put together these steps to help you out:
- First, we have to check the current hostname. So, open a terminal.
- Then, run this command:
hostnamectl
This command displays the current hostname along with other system information like architecture and kernel version.
- Then, run the following command to change the hostname:
sudo hostnamectl set-hostname newhostname
Remember to replace `newhostname` with our desired hostname.
This command changes the static (standard), transient (dynamic), and pretty (descriptive) hostnames all at once.
- Furthermore, we can change certain types of hostnames using additional options:
- Static Hostname:
sudo hostnamectl set-hostname --static newhostname
This updates the `/etc/hostname` file with the new static hostname without changing the transient or pretty hostnames. - Transient Hostname:
sudo hostnamectl set-hostname --transient newhostname
- Pretty Hostname:
sudo hostnamectl set-hostname --pretty "New Hostname"
Note that the pretty hostname can contain spaces and special characters, while static and transient hostnames should stick to letters, numbers, and hyphens.
- Static Hostname:
- After changing the hostname, verify it by running:
hostnamectl
- If the hostname hasn’t changed, we may need to restart the `systemd-hostnamed` service:
sudo systemctl restart systemd-hostnamed
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
In brief, our Support Experts demonstrated how to permanently change the hostname on Ubuntu.
0 Comments