initial-setup
initial-setup copied to clipboard
/etc/hosts not updated to reflect hostname set on initial setup
What Happened?
/etc/hosts
- has no entry for the hostname you set in the initial setup (e.g.
my-hostname
). - will contain references to the suggested hostname (e.g.
Inspiron-3583-abcdefgh
) even if you decide to use a different name.
Steps to Reproduce
- Install elementary, get to the initial setup
- In the last step, where you create a new user, define a custom hostname, such as
my-hostname
. The hostname field will be pre-filled with something likeInspiron-3583-abcdefgh
; delete that and set a custom name instead. - Login as that user and run
cat /etc/hosts
Expected Behavior
Expected contents of /etc/hosts
:
127.0.0.1 my-hostname.localdomain my-hostname localhost.localdomain localhost
::1 my-hostname.localdomain my-hostname localhost.localdomain localhost
Actual contents of /etc/hosts
:
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
127.0.0.1 Inspiron-3583-abcdefgh.localdomain Inspiron-3583-abcdefgh
It's a bit messy too, right? But the relevant problem here is the absence of my-hostname
.
OS Version
6.1 (Jólnir)
Software Version
Latest release (I have run all updates)
Log Output
No response
Hardware Info
- Dell Inspiron 15 3583
I believe this method is responsible for setting the hostname when the uesr clicks on the Finish Setup
button.
The utility method is here:
https://github.com/elementary/initial-setup/blob/e34c159d4e5d46b6d74a560ed59c47861c610c5a/src/Utils.vala#L186-L226
If I'm reading this correctly, we just use org.freedesktop.hostname1.set-static-hostname
and don't manually do anything else to set the hostname; I'd imagine the FreeDesktop DBus interface should handle that?
Also this proposed device name Inspiron-3583-abcdefgh
is used in syslog
and maybe other logs.
I have a bit more strange behavior. During installation I changed proposed Lenovo-IdeaPad-Y580-d4dce24c
to prid-PC
. Later during Dropbox authentication it showed me a pridPC
name without a dash. And the /etc/hostname
, /etc/hosts
files contained only the initially proposed Lenovo-IdeaPad-Y580-d4dce24c
name.
After changing manually the name in these 2 files and rebooting several times, I've noticed the Lenovo-IdeaPad-Y580-d4dce24c
name in syslog
:
Jan 25 02:29:42 Lenovo-IdeaPad-Y580-d4dce24c kernel: [26215.856346] [UFW BLOCK] ...
Something strange is going on with the device name.
This causes a secondary problem where sudo
commands are really slow if you choose anything other than the default hostname. See the following for reference: https://stackoverflow.com/questions/22249688/linux-sudo-is-working-slow-after-changing-the-hostname