-
Get the latest version WSL from the Windows Store
-
Ensure
/etc/wsl.conf
has[boot] systemd=true
-
Restart WSL by
wsl.exe --shutdown
Refer to
-
Edit
/etc/wsl.conf
like[network] hostname=your-host-name generateHosts=false
Replace
your-host-name
with your host name. -
Edit
/etc/hosts
, replacing every occurrence of the old host name with your new host name. -
Restart WSL by
wsl.exe --shutdown
Refer to:
Use a distro command like
ubuntu2204.exe config --default-user your-user-name
The issue is that when a WSL distro is open and Windows starts sleep, then the date time on the distro may be incorrect after the sleep. The fix is to to enable the systemd-timesyncd
service on the distro.
-
Ensure systemd is enabled as said by Enable systemd
-
Install
systemd-timesyncd
if not, bysudo apt install systemd-timesyncd
-
Edit its config by
sudo systemctl edit systemd-timesyncd
Ensure the config has
[Unit] ConditionVirtualization=
-
Start or restart it by
sudo systemctl start systemd-timesyncd
or
sudo systemctl restart systemd-timesyncd
Refer to