Change hostname CentOS 7.x

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

# show current hostname

[[email protected] ~]# hostname 

# change hostname

[[email protected] ~]# 

[[email protected] ~]# hostname   # just changed

[2]. Change hostname permanently

[[email protected] ~]# hostnamectl set-hostname

# show status

[[email protected] ~]# hostnamectl 

   Static hostname:
         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

Setting up an SSL secured Webserver with CentOS

This guide will explain how to set up a site over https. The tutorial uses a self signed key so...

Add Secondary IP Address to Centos

Just create a new interface file with a colon and a number....

I Need the Kernel Source

1. Maybe you do not need the full kernel source If you need to compile a...

Assign Additional IP Addresses in RedHat/CentOS

If you are using cPanel, you should add the IP addresses through WHM.  Do not follow...

Securing OpenSSH

OpenSSH (or Secure SHell) has become a de facto standard for remote access replacing...