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.


or use 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  Easy Show Routes (routing table) in Linux
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

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.

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...
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
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