Ask Your Question

hostname keeps changing after reboot

asked 2018-05-21 09:14:31 -0500

dylanthomas gravatar image

so my transient hostname keeps changing after almost every reboot despite having correct hostname in.

$ /etc/hosts

$ /etc/hostname

I have to enter the $ hostnamectl set-hostname localhost every time i log in.

is there anyway i can set my hostname permanently?

edit retag flag offensive close merge delete


man nsswitch.conf

fcomida gravatar imagefcomida ( 2018-05-21 15:45:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-05-21 16:49:34 -0500

frantou gravatar image

The easiest way to set your hostname permanently is to choose a hostname different from localhost, because with this specific static hostname, a transient hostname will be used (which is typically not localhost).

The hostnamectl manpage puts it this way:

If a static hostname is set, and is valid (something other than localhost), then the transient hostname is not used.

So unless you really want your hostname to be localhost, you could set your static hostname to something else, like lo and you will no longer be bothered with a transient hostname:

# hostnamectl set-hostname lo

Note: you may (or may not) have to adapt your /etc/hosts file to reflect the change.

edit flag offensive delete link more

Question Tools



Asked: 2018-05-21 09:14:31 -0500

Seen: 579 times

Last updated: May 21 '18