Change hostname by hostnamectl

Change Hostname on CentOS/RHEL/OEL 7



Assalamu’alaikum Wr. Wb.
My machine running CentOS Linux release 7.3.1611 (Core). There are some different between redhat based version under 7 and and above 6, include the commands. In this case, I wanna change the hostname from jeruk.buah.net to rhino.animal.net. At the redhat based version under 7, I can change by /etc/sysconfig/network. So, how about version 7 and above? It replaced by hostnamectl command.

Current Hostname on CentOS 7.3.1611
Current Hostname on CentOS 7.3.1611


It is simple. Login as root in terminal and change the hostname by hostnamectl command:


hostnamectl set-hostname rhino

hostnamectl set-hostname rhino.animal.net –static

hostnamectl status

Change hostname by hostnamectl
Change hostname by hostnamectl


That’s it! and then change the /etc/hosts.

Edit /etc/hosts
Edit /etc/hosts


Logout and relogin.

Logout and relogin
Logout and relogin


Wassalamu’alaikum 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s