CentOS 6 modify the hostname (hostname) need to modify two places: one is /etc/sysconfig/network, the other is /etc/hosts, only modifying any one will cause the system to start abnormally. First switch to the root user.
Open the file, there is a line HOSTNAME=localhost.localdomain (if it is the default), modify localhost.localdomain to your hostname.
Open the file, there will be a line 127.0.0.1 localhost.localdomain localhost. Among them, 127.0.0.1 is the local loop address, and localhost.localdomain is the hostname, which is what you want to modify. localhost is the alias of the host name, which will appear at the Konsole prompt. Change the second item to your hostname, the third item is optional.
After the above two files are modified, they will not take effect immediately. If you want to take effect immediately, you can use
For temporary modification, it only temporarily modifies the host name, and it will be restored after the system restarts. But modifying the above two files is permanent, and restarting the system will get the new host name.
Finally, check the host name after restarting: