Main menu

Change hostname in Linux

When you install Linux or probably get a VPS server it’s comes with a default hostname. As you creating any file server and web server probably you need to change your hostname to something else.

Check your hostname

# hostname
localhost.localdoamin

Default installation of Linux  host-name is localhost.localdomain. To change this you can follow the following steps

Change host-name CentOS or RedHat5 and 6

# vi /etc/sysconfig/network
HOSTNAME=technet.sector19.net

On latest version of RHEL7 or CentOS7 with systemd capability you can change hostname with hostnamectl command

# hostnamectl set-hostname technet.sector19.net

Verify updated name

# hostnamectl
   Static hostname: technet.sector19.net
         Icon name: computer-vm
            Chassis: vm
        Machine ID: f7bfb9616d974929a24b51b0ea525b45
              Boot ID: 00233286501e4e6ca968ca404898dfef
      Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.4.5.el7.x86_64
      Architecture: x86-64

Change host file entry for local name resolution.

# vi /etc/hosts
127.0.0.1 technet.sector19.net
FacebookTwitterGoogle+RSS