banner



How To Change Hostname In Centos 7

The hostname of a system tin be used to make it easier to identify the host and not rely on an IP address which is difficult to remember.  There are numerous means to change the hostname, and some of them volition not last through a arrangement reboot.  In this commodity, I volition show you how to alter the hostname of CentOS vii permanently. Let's get started.

Option 1 – Irresolute the Hostname Using hostnamectl

Y'all can run the post-obit command to cheque for the current hostname of your CentOS 7 machine:

As you tin come across from the screenshot below, the electric current hostname of my CentOS 7 server is linuxhint

You lot tin can use hostnamectl command to alter the hostname of your CentOS 7 auto equally follows:

$ sudo hostnamectl set-hostname NEW_HOSTNAME

Let'south change it from linuxhint to linuxmint for fun with the following control!

$ sudo hostnamectl gear up-hostname linuxmint

The hostname should be changed to linuxmint. You can verify that it changed with the following command:

Equally you can come across the hostname is changed to linuxmint!

If you log out and log back in to your CentOS 7 machine or restart it, the changes should be applied system wide.

Option 2 – Changing the Hostname using nmtui:

nmtui control line program is available in NetworkManager-tui bundle. The NetworkManager-tui package is available in the official package repository of CentOS 7.

To install NetworkManager-tui, run the following command:

$ sudo yum install NetworkManager-tui

Press 'y' and and so press <Enter> to continue.

NetworkManager-tui should be installed.

Now you tin can run the following command to start nmtui Terminal based graphical interface:

You lot should see the following window equally shown in the screenshot. Now press <Down> arrow central a few times to select the marked option "Set arrangement hostname" and press <Enter>

One time you press <Enter>, yous should see the following window as shown in the screenshot below.

Yous tin can just type in a new hostname in the textbox and press <OK>.

I am going to change the hostname from linuxmint to linuxhint again.

Once you press <Enter>, y'all should meet the following window. Press <Enter> once more.

Now select Quit and press <Enter>. The hostname should be changed.

Yous can verify that the hostname actually changed with the following command:

As you lot tin meet from the screenshot beneath that the hostname is inverse from linuxmint to linuxhint. Great! A full organisation restart may exist required for the changes to take event system wide.

Fixing Hostname Resolution

By default, when you change hostname, information technology won't resolve automatically to localhost or 127.0.0.1

To fix that, open up the /etc/hosts file with the following command:

The file should be opened.

Now add the following line equally marked in the screenshot below and salvage it.

Now y'all can ping your newly set hostname as well.

So that'south how you modify the hostname of CentOS 7 permanently. Thanks for reading this article.

Nearly the writer

Freelancer & Linux System Administrator. Also loves Spider web API evolution with Node.js and JavaScript. I was born in People's republic of bangladesh. I am currently studying Electronics and Advice Engineering science at Khulna University of Engineering & Engineering science (KUET), one of the demanding public engineering universities of People's republic of bangladesh.

Source: https://linuxhint.com/change-hostname-centos7/

Posted by: kingtordese.blogspot.com

0 Response to "How To Change Hostname In Centos 7"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel