Monday, July 8, 2013

Changing Hostname in Linux

To see current hostname

# hostname

change hostname temporary

# hostname myhostname.com

Now see new hostname

# hostname

To change the hostname permanently

# vi /etc/sysconfig/network

change the hostname variable then save and exist

Now you have add your new hostname into /etc/hosts file

# vi /etc/hosts

Add your new hostname and If you want you can remove the old hostname from the file

Then save and exist

Now its time to restart your server.

You can also try restarting network service

In Ubuntu/Debian

# service network restart

In CentOS/Red Hat/Fedora

# service networking restart


If you want you can use GUI tool too

# system-config-network

And now follow the wizard

Finally Restart the server

No comments:

Post a Comment