Centos 6 Change Hostname

This post will guide you how to change hostname on CentOS Linux 6 system. You can use the dnsdomainname command to display or set the current system’s DNS domain name, using the HOSTNAME command to set or display the current hostname of your Centos 6 system.

CentOS 6 Display Current Hostname

If you are using a Centos 6.x system, you can also directly run the hostname command to view the current hostname, type:

#hostname

If you want to display current domain name on CentOS 6 system, you need to use the DNSDOMAINAME command under command line option, type:

#dnsdomainname

Outputs:

osetc.com

CentOS 6 Change Hostname

If you want to change the hostname on CentOS 6 Operating system, you need to update the hostname config file /etc/sysconfig/network, just do the following steps:

#1 edit the /etc/sysconfig/network file via VI/VIM command, type:

#vi /etc/sysconfig/network

#2 change HOSTNAME value to the new hostname, like this:

HOSTNAME="osetc.com"

#3 Save and close the file.

#4 edit /etc/hosts file to change the old hostname to new hostname.

If you just only want to set hostname manually without rebooting the system, just execute the following command:

#hostname osetc.com

You might also like:

Sidebar



back to top