The hostname
of your CentOS 7 Linux is defined by the file /etc/hostname
thus setting a new hostname for your system is just a matter of editing this file and replace a current hostname definition line with new one. However, doing so will not update your system;s hostname immediately thus a preferred way of changing a hostname on CentOS 7 Linux is to use nmtui
and more specifically its child nmtui-hostname
. Using nmtui-hostname
tool will make the process of changing your hostname rather simple as executing a single command. The following linux command will change the hostname to linuxconfig.org
:
# nmtui-hostname linuxconfig.org

Hit the “OK” button on the pop-up dialog and you are done.
# hostname linuxconfig.org