This guide explains you how to change your hostname on your linux machine.

How to change hostname in Redhat / CentOS / Fedora / RHEL

I would like to set “client52.linuxinternetworks.com”  as a hostname name for my client host and 192.168.1.52 is my private ip address.  We need to edit some configuration files in order to change the hostname

Prerequisite

  1. IP address of your host.
  2. You need super user privileges

Edit the hosts file as shown below, save and quit it.

vim /etc/hosts
192.168.1.52 client52.linuxinternetworks.com

Edit the network file as shown below, save and quit it.

vim /etc/sysconfig/network
HOSTNAME = client52.linuxinternetworks.com
# sysctl kernel.hostname=client52.linuxinternetworks.com

This sysctl command is used to configure the kernel parameters at run time.

Now check your hostname

# hostname

client52.linuxinternetworks.com

How to change hostname in ubuntu / Debian

Here in this ubuntu/debian I would like to set up the same hostname “client52.linuxinternetworks.com” and I am having the same private ip address 192.168.1.52

Prerequisite

  1. IP address of your host.
  2. You need super user privileges.

Edit the hostname file as shown below, save and quit it.

vim /etc/hostname

client52.linuxinternetworks.com

# sysctl kernel.hostname= client52.linuxinternetworks.com

This sysctl command is used to configure the kernel parameters at run time.

Now check your hostname

# hostname

client52.linuxinternetworks.com

Related articles


Subscribe Our Free Newsletter

Delivered by FeedBurner. We Respect Your Privacy

Tagged with:
 

One Response to How to change hostname in linux

Leave a Reply