Hostnamectl is a newly added command in Centos7, it is used to modify the host name, CENTOS7 modifying the host name will be much easier than ever.
usage
# hostnamectl-h -H--help Display Help --version Displays the version of the installation package --transient Modify the temporary hostname --static Modify the transient hostname --pretty Modify the flexible hostname -P--privileged the privileges obtained before execution --no-ask-password Enter the password without prompting - H--host=[[email protected]]host operation remote host commands: status Display current hostname settings set-hostname name Set the system hostname set-icon-name Name set the host platform type name for the host setting icon name Set-chassis name
There are three definitions of host names in CentOS7: static, transient (transient), and flexible (pretty). The static hostname, also known as the kernel hostname, is the hostname that the system automatically initializes from within/etc/hostname at startup. A transient hostname is a host name that is temporarily assigned when the system is running. A flexible hostname allows the use of a host name with special characters.
Common Commands
1. View status
# Hostnamectl or # Hostnamectl status (shows the same results) Static hostname:localhost.localdomain Icon Name: COMPUTER-VM CHASSIS:VM Machine id:049717292ec9452890e50401d432e43c Boot ID: 2e69a66a7c724db6a44a8536f1670f7f VIRTUALIZATION:KVM Operating system:centos Linux 7 (Core) CPE OS Name: Cpe:/o:centos:centos:7 kernel:linux 3.10.0-229.el7.x86_64 architecture:x86_64
2. Modify the host name
# hostnamectl set-hostname linuxprobe# hostnamectl status Static hostname:linuxprobe pretty hostname: Linuxprobe Icon name:computer-vm chassis:vm machine id:dc99c115d7414d159fa4c5c0c0541c55 Boot ID: 6236b67c13af4d98b5fa3780e66dfdeb VIRTUALIZATION:KVM Operating system:centos Linux 7 (Core) CPE OS Name: Cpe:/o:centos:centos:7 kernel:linux 3.10.0-229.el7.x86_64 architecture:x86_64
Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/
Use of Hostnamectl in CentOS 7