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
hostname change centos 7 linux command
Hit the "OK" button on the pop-up dialog and you are done.
# hostname
linuxconfig.org
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: