Two changes need to be modified: one is/etc/sysconfig/network and the other is/etc/hosts, and only modifying any of them will cause system startup exceptions. First switch to the root user.
Open the file with any of your favorite editors, with a line of Hostname=localhost.localdomain (if default), and modify Localhost.localdomain to your hostname.
Open the file, there will be a line 127.0.0.1 localhost.localdomain localhost . Where 127.0.0.1 is the local loop address, Localhost.localdomain is the hostname (hostname), which is what you want to modify. localhost is the alias of the hostname, which appears under the Konsole prompt. Change the second item to your hostname, and the third option is optional.
After modifying the above two documents, it will not be effective immediately. If you want to take effect immediately, you can use hostname your-hostname for temporary modification, it just temporarily modifies the hostname, the system restarts will be restored as is. However, modifying the above two files is permanent, and rebooting the system will give you a new host name.
CentOS Modify host name (hostname)