Monday, 23 May 2016

HostnamectlOnCentOS 7 Linux


Hostnamectl is a new utility which has been added to CentOS 7 Linux systems. It gives you more control over the way we set or play with Linux system's hostname. It is important to understand that proper or Full qualified hostnames of a Linux system is vital for the proper communication of data. In earlier days, we used to edit files manually to set the hostname of Linux systems. Linux operating system has been an ever evolving operating system. Keeping in mind the needs of user, hostnamectl utility has been added to the operating system so you may set, change, and configurehostnames of your Linux systems easily and properly. Linux operating system is currently having this utility available in CentOS and RHEL 7 only. Other operating system might introduce it soon.


Type "hostnamectl" on the command line and it should show the current details of the system like its hostname, operating system version, and some of the hardware specifications.


                


In order to set a new hostname for your CentOSmachine, run following command.

hostnamectl set-hostname New-Name

Similarly, it also lets you configure both static and pretty hostnames of your Linux operating system. In order to set static hostname, command should be:

hostnamectl set-hostname New-Name --static

In order to set pretty hostnames, command should be as follows.

hostnamectl set-hostname "Linuxpitstop Hostname" --pretty


This utility has really simplified the way we handle hostname related operations on a CentOS Linux system. You don't need to go around editing individual files now, use this utility and you should be good to go. In earlier versions of CentOS operating system, we used to edit /etc/hosts, resolve.conf and network files to setup new hostnames; and any syntax mistakes would lead to unexpected errors/issues. This command is now an easy and safest way to handle such important matter.

0 comments:

Post a Comment