Changing the hostname on WSL

Viewed 39731

I recently reinstalled Windows 10 and my hostname is DESKTOP-XXXXXX. I'm trying to change it to something else. I tried the following:

sudo hostname wsl

I also changed /etc/hostname to "wsl" and changed /etc/hosts to "127.0.1.1 wsl.localdomain wsl".

Every time I restart WSL, it resets the hostname. How do I change the hostname permanently?

2 Answers

In Windows 10 Home 64-bit, Fall Creators Update edition (Version 1709, Build 16299.19) I used:

SettingsSystemAboutRename this PC

After that a restart is required.

Related