hostname is different from /etc/hostname and /etc/hosts
On a new system install of Fedora 22 KDE my hostname was initially localhost
but it changed on its own. It is now dhcpp5
. There is no mention of it in /etc/hostname
or /etc/hosts
. Is that some new naming scheme or a bug?
[sudhir@dhcppc5 ~]$ hostname
dhcppc5
[sudhir@dhcppc5 ~]$ cat /etc/hostname
localhost.localdomain
[sudhir@dhcppc5 ~]$ cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
Just for your information,
/etc/hosts
has nothing to do with your computer's hostname. It's there to provide static resolution of host names to IP addresses without needing DNS. As an example, if a domain's records aren't properly updated you can add the correct info to the file so that you can reach the site. And, of course, if you want to make a site permanently unreachable, you can add an entry giving it an IP of 127.0.0.1 so that you'll never get there again, even by accident or an auto-redirect.Is it advisable to add
hostname
to/etc/hosts
as it happens with a new system install?Not unless you expect to need to connect to your own machine by name instead of just using localhost.