MilesWeb Hosting Forum

Web Hosting Technical Support => How To's => Topic started by: Dipak Bhoi on January 21, 2014, 11:32:37 PM

Title: How to set hostname to your server ?
Post by: Dipak Bhoi on January 21, 2014, 11:32:37 PM
Hello guys,

This post cover how to set the server hostname on linux.

Quotelogin as: root 
    root@example.com's password: 
    Last login: Tue Jan 21 06:33:17 2014
    [root@example ~]# hostname 
    example.com
 

You can also check via sysctl kernel.hostname

Quote#sysctl kernel.hostname 
    kernel.hostname = example.com 

I wish to set for this server is instructor.example.com
Quote# hostname instructor.example.com 

This will set the hostname.
Quote# hostname 
    instructor.example.com 
once the server is rebooted, hostname is changing to example.com.

To permanently change the hostname, You need to edit the network file at /etc/sysconfig/network

Quote#vi /etc/sysconfig/network
   
NETWORKING=yes 
HOSTNAME=example.com 
GATEWAYDEV=eth0 
GATEWAY=192.168.0.1

You will have to edit the HOSTNAME entry.

QuoteHOSTNAME=instructor.example.com 

Enjoy !!!