Changing the hostname on WSL

Leo Jiang picture Leo Jiang · Jul 2, 2017 · Viewed 20.5k times · Source

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?

Answer

WinEunuuchs2Unix picture WinEunuuchs2Unix · Oct 30, 2017

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.