How to change hostname in Linux

Опубликовано: 28 Август 2026
на канале: Slap Ya Administrator
1,148
11

Learn how to change hostname in Linux. I am using Ubuntu 20.04 in my demo.

The other commands features in my video what?

Login as super user
sudo su

Quick check (works on older systems)
hostname
Detailed system information.
hostnamectl

Edit local DNS (Domain Name System) resolver
nano /etc/hosts

Permanently changes your Ubuntu system's hostname to csrt4
hostnamectl set-hostname csrt4

Apply hostname
reboot

At this point, you can say that your host name changes are complete, but,
it is highly recommended to reboot your Linux box.
Reason being that some services and application cache hostname until it is rebooted.
Also, NetworkManager, DHCP, and DNS resolvers may retain the old hostname until restarted.
And same thing applies to security policies like Kerberos, SSH host keys, or SSL certificates.
Rebooting ensures all services use the same, updated hostname consistently.
Now I can lobby for a reboot until I turn blue, but if reboot is not an option for you, you can also manually restart critical services instead rebooting your Linux machine using the systemctl command.

#linux #ubuntu