How to change hostname on CentOS Linux

Hostname Change

There are 4 steps in a hostname change, luckily all the steps are easy.

Sysconfig/Network

Open the /etc/sysconfig/network file with your favorite text editor. Modify the HOSTNAME= value to match your FQDN host name.


# sudo nano /etc/sysconfig/network

HOSTNAME=myserver.domain.com

Hosts File

Change the host that is associated to your main IPaddress for your server, this is for internal networking (found at /etc/hosts):


Run Hostname

The 'hostname' command will let you change the hostname on the server that the commandline remembers, but it will not actively update all programs that are running under the old hostname.

Restart Networking

At this point all the necessary changes that needed to be made have been made, you will want to restart networking on your server to make sure that changes will be persistent on reboot:

# /etc/init.d/network restart




  • 46 gebruikers vonden dit artikel nuttig
Was dit antwoord nuttig?

Gerelateerde artikelen

How to Reset Mysql passowrd

  Step # 1 : Stop mysql service # /etc/init.d/mysql stop Output: Stopping MySQL database...

How to Change SSH Port in Centos

Login into your Server Via Putty or any SSH client.type in following...

Reset forgotten root password on CentOS

1. Boot the system and when you see the following message "Press any key to enter the...

Linux Firewall Fail2Ban

How To Protect SSH with fail2ban on CentOS 6  Step One—Install Fail2Ban Because...

Adding and viewing IP addresses on CentOS servers

To add newly assigned IP addresses from SSH, follow this procedure: (Please follow the steps...