Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the hostname on WSL [closed]

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?

like image 345
Leo Jiang Avatar asked Jul 02 '17 09:07

Leo Jiang


People also ask

Does wsl require admin rights?

Administrator privileges in Windows are required to run OpenSSH in WSL. To run an OpenSSH server, run your WSL distribution (ie Ubuntu) or Windows Terminal as an administrator.


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.

like image 62
WinEunuuchs2Unix Avatar answered Oct 01 '22 13:10

WinEunuuchs2Unix


Try to change the host system's name from System --> Change Settings --> Change. It makes sense for WSL to update its hostname to match that of the host computer.

like image 28
ifconfig Avatar answered Oct 01 '22 15:10

ifconfig