Change / Set the Host name in Linux

To check the host name use the below command

#hostname

This will display the host name if already set

To Change the host name temporarly use the below command

#hostname NEW-NAME

To make the changes permanent we need to edit two files

1)Network File
2)/etc/hosts file

1)Redhat / CentOS / Fedora: Change Hostname

vi /etc/sysconfig/network
HOSTNAME=NEW-NAME

Set only the host name not the domain name extension

2)vi /etc/hostname
Enter the ipaddress followed by  host name without domain extension after a space

192.168.0.1    NEW-NAME

Leave a Reply

Your email address will not be published. Required fields are marked *

*