How to change the hostname in Linux

This article describes the how the change the hostname in Linux machine.

Let’s start.

  • Open the network file.
 # sudo vi /etc/sysconfig/network
  • Modify the HOSTNAME= value with your domain name. Example hostname is “myhostname”
HOSTNAME = myhostname
  • To access with in the server add it in /etc/hosts file
127.0.0.1 myhostname
  • Run the “hostname” command. This command lets you change the hostname on the server that the command line remembers, but it does not actively update all programs that are running under the old hostname.
[root ~]# hostname myhostname 
[root]# hostname 
myhostname
[root ~]#
  • Restart networking on your server to ensure that changes will persist on restart.
# /etc/init.d/network restart
Advertisements


Categories: Linux

Tags: ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: