habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Simple Method Change Hostname Linux

1 min read

Simple Method Change Hostname Linux

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
Simple Method Change Hostname

Or you want to show Full Hostname FQDN.

hostname -f
Simple Method Change Hostname

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.

See also  Wget Recursively Download All Files and Folder
Simple Method Change 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.

Buy Me a Coffee at ko-fi.com

https://saweria.co/habibzain
https://ko-fi.com/habibzain
habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Centos Failed Update Kernel

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel...
habibzain
1 min read

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox