[root@localhost ~]# hostname hello
[root@localhost ~]# hostname
hello
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@localhost ~]#
The command line output is as above.
Why is the hostname
output different from what is found in /etc/hosts
?
The system hostname is not set using the file /etc/hosts
.
The hostname is set using the system configuration management system. Where the hostname is stored persistently depends on the distribution. For instance, on my kali machine the hostname is stored in the file /etc/hostname
from where it is read during startup; on my gentoo machine it is stored in /etc/conf.d/hostname
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments