HostOnNet Blog

Setting HostName in Linux

Looking for Linux Server Admin or WordPress Expert? We can help.

To set host name on a CentOS/RHEL/Fedora Server to

Edit /etc/sysconfig/network

vi /etc/sysconfig/network



Replace With

Edit /etc/hosts

vi /etc/hosts



To find servers main IP, use ifconfig, it should be IP of eth0 in most cases.

Add hostname to /etc/hostname

echo > /etc/hostname

Setting HostName With out reboot

/bin/hostname -F /etc/hostname

Reboot Server

Finally you need to reboot. Make sure you done the changes properly before rebooting. If you made some mistake, server may not come back online with out assistance from Data Center, not every DC will do this, you may need to fix yourself by logging into KVM or rebooting server into rescue mode, so always verify before rebooting.


Verify Host Name Change


Should know new hostname.

Posted in CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.