Advanced

Commands to Configure hostname on CentOS 7 and RHEL 7

Posted by linuxtechi on · 6 comments
linuxtechi.com; By Pradeep Kumar
Mail this story
Print this story

Hostname is defined as label or name of a computer and network device.hostnamectl, nmtui and nmcli commands are used to configure hostname on CentOS 7 and RHEL 7.

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: Linux, Red Hat

» Get new stories by e-mail: nightly or as they are published

« Return to the newswire homepage

  Related stories
» More like this

Comments (6)

On my Slackware boxes, I just put the hostname in /etc/HOSTNAME and /etc/hosts. No 'hostnamectl' nonsense here.
One more reason that I'm happy to keep my servers on CentOS 6, no hostnamectl nonsense there either.

> I just put the hostname in /etc/HOSTNAME and /etc/hosts.

Does that change the current name, or does it only take effect when the machine is rebooted? I was under the impression you had to use the hostname command to change the current name. But I've never had to change the hostname on a running machine, so I'm not certain.
@jdixon:

You are correct.

$man hostname

/etc/hostname Historically this file was supposed to only contain the hostname and not the full canonical FQDN. Nowadays most software is able to cope with a full FQDN here. This file is read at boot time by the system initialization scripts to set the hostname.
I just used hostnamectl to change that name 2 days ago and did not reboot. No problem until now. That doesn't seem a nonsense utility. Is it because it's a systemd tool ?
> just used hostnamectl to change that name 2 days ago and did not reboot.

You don't need to reboot if you use the hostname command either. It just that (for Slackware) if you only change /etc/HOSTNAME, it's only read on a reboot.

Post a comment

A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.

Your message:
|||||
10
Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help

Sign up and post (it is free)  or  Log in and post