5

Many websites says I should use lxrun /setdefaultuser, but this command is deprecated:

C:\WINDOWS\system32>lxrun /setdefaultuser foo

Warning: lyrun.exe is only used to configure the legacy Windows Subsystem for Linux distribution.

How can I change the default username which is in my case root. I would like it to be the same username as I use with my Windows account.

Btw I am using mintty to run WSL:

%LOCALAPPDATA%\wsltty\bin\mintty.exe --WSL= -h err --configdir="%APPDATA%\wsltty" -~ 
  • Could be but there is no /setdefaultuser option :( – nowox Nov 9 '17 at 12:32
  • @Ramhound: Why did you post a bounty when your own answer is accepted? – harrymc Jan 22 '18 at 15:24
  • @Ramhound: I have the exact same question :) – nowox Jan 22 '18 at 15:27
  • Does the accepted answer solve your issue? – nowox Jan 22 '18 at 15:45
  • @Ramhound: What do you expect to achieve? Do you intend to never award the bounty, so nobody gets more than half the bounty and that also only if at least two voters happen to like the answer in the next 5-6 days? You know well that most voters will only look at the accepted answer and go away uninterested. – harrymc Jan 22 '18 at 16:28
9

Microsoft has documented how this is done on Fall Creators Update and later. The commands suggested are only an example and might vary based on the WSL instance you are using.

This question was asked in 2017, so the name of the WSL instance, might no longer be applicable to a newer version of Ubuntu WSL or if a different WSL distribution is being used. The commands that are suggested will work with any WSL distrubition on the Windows Store.

To see what commands are available for a particular distribution, run [distro.exe] /?.

For example, with Ubuntu installed:

C:> ubuntu.exe /?

enter image description here

Which means in order to change the default user to root in Ubuntu you would use the following command.

C:\> ubuntu config --default-user root

The documentation indicates the following:

enter image description here

Source: User Accounts and Permissions

  • I wouldn't have been able to find the documentation page if it wasn't for this answer so be sure to give it an upvote. – Ramhound Nov 9 '17 at 16:10
  • How to set default user to root in WSL also submitted a similar answer but I didn't find it until after I submitted my answer. – Ramhound Nov 9 '17 at 16:13
  • My answer was correct when it was submitted in 2017. According to the article it still is valid. – Ramhound Apr 25 at 11:02
  • This question and answer is from 2017. Newer versions of WSL instances would come with it own executable. In this case it’s specific to the instance from 2017 not 2018. The commands suggested are examples and specifically geared towards the author’s question. This answer is absolutely correct in the context of the author’s question – Ramhound Apr 25 at 11:07
  • Thanks for updating the question to reflect this, it will save people time explicitly stating that in the question as you have (especially noobs like me!). Thanks again! – rmcsharry Apr 25 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.