0
[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?

1 Answer 1

2

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.

2
  • My distro is fedora, which file is used to store the information? Commented Sep 29, 2016 at 15:20
  • According to this question unix.stackexchange.com/q/162393/64248 and its answer you use the command hostnamectl. Beyond that, I am not at all familiar with Fedora. Commented Sep 29, 2016 at 15:30

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.