How to Change the Hostname of CentOS or RedHat Linux systems?

We can change the hostname of a machine by several ways. I am mentioning two ways to change the hostname.

Method 1 :- Editting /etc/sysconfig/network file

  1. Open the terminal or Login with putty.exe as root user (if you are working remotely)
  2. Goto /etc/sysconfig/
  3. Type nano network
  4. Change the HOSTNAME to your preferred machine name
  5. Press Cntrl+X
  6. Save the configuration by pressing Y
  7. Log off or reboot

Method 2:- Editting  /proc/sys/kernel/hostname file

  1. Open the terminal or Login with putty.exe as root user (if you are working remotely)
  2. Goto /proc/sys/kernel/
  3. Type nano hostname
  4. Change the HOSTNAME to your preferred machine name
  5. Press Cntrl+X
  6. Save the configuration by pressing Y
  7. Close the terminal and login again

In this method, no reboot is required to get the change in effect

Note: Add the ipaddress and new hostname to /etc/hosts file also

Advertisements

About amalgjose
I am an Electrical Engineer by qualification, now I am working as a Software Engineer. I am very much interested in Electrical, Electronics, Mechanical and now in Software fields. I like exploring things in these fields. I like travelling, long drives and very much addicted to music.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: