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