Hi Dude. Hostname is very important for server and first time basic configuration wizard when deploy server. So what if forget set hostname? There is simple method change hostname linux. This post today, i will explain simply about change hostname.
Hostname is the identity of the name of a server. With the hostname we know the name of the server when communicating with other servers, or when scanned for network discovery. The goal is identify, and minimize server swapping. This would be very stupid. :D. LOL.
But take it easy, there is an IP address that makes the address and hostname unique. Ha ha ha. Lets do it. Execute command, run, get result. May be i am over. 😀
At First, Check the current hostname
We can use hostname
command.
hostname
or use hostnamectl
.
hostnamectl
Or you want to show Full Hostname FQDN.
hostname -f
From the three different command above, we know that the server hostname is zimbra9.habibza.in.
Procedure 1: Change Hostname
Commonly Hostname is configured in /etc/hostname
file. So we have to edit manually and change hostname there.
vim /etc/hostname
Delete the current name in this file, and input new name host server. And then save it.
Check hostname again with hostname
or hostnamectl
command. Maybe required reboot to resolve new hostname.
Update /etc/hosts file
Another way we also need to do is to update /etc/hosts
file. Just replace the old hostname with the new hostname. Replace green line and red line and change to new hostname.
And then reboot.
Procedure 2: Change Hostname with Hostnamectl
sudo hostnamectl set-hostname <newhostname>
This command will remove the old hostname from /etc/hostname
and put the new hostname in its place. As with the first method, we need to update /etc/hosts
file. Dont forget to reboot.
Easy right? That is simple method change hostname Linux. Hope it’s helpful, please feel free to leave a comment if you have any questions and I’ll appreciate it.
Let's Buy Me Coffee. https://saweria.co/habibzain https://ko-fi.com/habibzain