Change hostname CentOS 7.x

[1]. Change hostname. (but if rebooting, it will be back).

# show current hostname

[[email protected] ~]# hostname 
localhost.localdomain

# change hostname

[[email protected] ~]# 
hostname srv.serversub.com 

[[email protected] ~]# hostname srv.serversub.com   # just changed


[2]. Change hostname permanently

[[email protected] ~]# hostnamectl set-hostname srv.serversub.com

# show status

[[email protected] ~]# hostnamectl 

   Static hostname: srv.serversub.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 98a49a78fc9ad91f1b99304c75b94c31
           Boot ID: 09b95ce0bc7f4179b1e8a011ed314c6b
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-123.4.2.el7.x86_64
      Architecture: x86_64

Was this answer helpful?

 Print this Article

Also Read

rsnapshot backups

This guide will assist you in setting up an rsnapshot backup server on your network. It will...

Install vnStat Network Traffic Monitor To Keep a Log Of Daily Traffic on CentOS / RHEL

How do I install vnstat software - a console-based network traffic monitor under CentOS or RHEL...

How to change my ssh port

IMPORTANT: Beofre changing your port, make sure the new port is whitelisted in your firewall, if...

Install Squid on CentOS / RHEL 5

Use yum command as follows:# yum install squidOutput: Loading "installonlyn" plugin Setting up...

Enable & Install EPEL Repo on CentOS / RHEL / Scientific Linux 6

Extra Packages for Enterprise Linux (or EPEL) is a Fedora Special Interest Group that creates,...