how to setup host name in Linux version 7 RHEL 7/Centos 7
In Redhat Enterprise Linux 5 and version 6 we have to edit file located in /etc/sysconfig/network but in Redhat Enterprise Linux 7 and Centos 7 no need to edit that config file we can directly change hostname using below commands how to setup host name in Linux version 7
- hostnamectl
- nmtui
- nmcli
in Redhat Enterprise Linux 7 there are three types of names we can assign, they are below
pretty – pretty option is used to set the name which may contain limited special characters
transient – this name we can use as temporary name whenever we exit from the session this name will go off
static – Static name is the permanent name for the host
Note that the pretty hostname has little restrictions on the characters used, while the static and transient host names are limited to the usually accepted characters of Internet domain names.
How to setup an hostname using hostnamectl command
[root@Arkit-SRV1 ~]# hostnamectl status Static hostname: Arkit-SRV1 Icon name: computer Chassis: n/a Machine ID: 41384f19fc57477680b0c7942ff29eb3 Boot ID: 11a7b1d4fd7f44f9b486e3ea0119e49d Virtualization: vmware Operating System: Red Hat Enterprise Linux Server 7.1 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.1:GA:server Kernel: Linux 3.10.0-229.el7.x86_64 Architecture: x86_64 [root@Arkit-SRV1 ~]# hostnamectl set-hostname "This is ARKTI's website" --pretty [root@Arkit-SRV1 ~]# hostnamectl status Static hostname: Arkit-SRV1 Pretty hostname: This is ARKTI's website Icon name: computer Chassis: n/a Machine ID: 41384f19fc57477680b0c7942ff29eb3 Boot ID: 11a7b1d4fd7f44f9b486e3ea0119e49d Virtualization: vmware Operating System: Red Hat Enterprise Linux Server 7.1 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.1:GA:server Kernel: Linux 3.10.0-229.el7.x86_64 Architecture: x86_64
as you can see above screen pretty name is changed
[root@Arkit-SRV1 ~]# hostnamectl set-hostname arkit-server --static [root@Arkit-SRV1 ~]# hostname arkit-server
see the above example hostname has been changed as mentioned as static
Static name can also be changed using config file
[root@Arkit-SRV1 ~]# cat /etc/hostname arkit-server
edit /etc/hostname file and write your hostname which will be permanent and static name for your server
[root@Arkit-SRV1 ~]# hostnamectl set-hostname arkit-temphostname --transient [root@Arkit-SRV1 ~]# hostnamectl Static hostname: arkit-server Pretty hostname: This is ARKTI's website Transient hostname: arkit-temphostname <<temp name has been updated Icon name: computer Chassis: n/a Machine ID: 41384f19fc57477680b0c7942ff29eb3 Boot ID: 11a7b1d4fd7f44f9b486e3ea0119e49d Virtualization: vmware Operating System: Red Hat Enterprise Linux Server 7.1 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.1:GA:server Kernel: Linux 3.10.0-229.el7.x86_64 Architecture: x86_64
Setup Hostname Using nmtui Command
[root@Arkit-SRV1 ~]# nmtui
select ‘Set system hostname’
Click on OK
Provide your hostname and click ok
it will show the hostname for your confirmation click on OK
go and verify your hostname using ‘hostname‘ and ‘hostnamectl status‘ commands
Changing the hostname using nmcli command
[root@Arkit-SRV1 ~]# nmcli general hostname Arkit-SRV1 [root@Arkit-SRV1 ~]# hostname Arkit-SRV1 [root@Arkit-SRV1 ~]# systemctl restart systemd-hostnamed.service
change your hostname as shown above example and restart the systemd-hostnamed service to effect newly changed hostname.
That’s about the hostname change in RHEL 7 version and Centos 7 version how to setup host name in Linux version 7 how to setup host name in Linux version 7 how to setup host name in Linux version 7 how to setup host name in Linux version 7 how to setup host name in Linux version 7 how to setup host name in Linux version 7
Please provide your valuable feedback.
Related Articles
What is A Redhat Administrator?
Operating system RHEL 7 Installation
Complete RedHat Enterprise Linux Beginner Guide
Thanks for your wonderful Support and Encouragement