WSL / Bash on Windows 10: Creating UNIX user failed, returned error code 10

6,879

Solution 1

Months later, I went back to this computer and managed to fix the problem by updating Windows 10 (from Version 1703 to 1803) and doing a fresh re-install through the Microsoft Store.

Here's a quote from Microsoft's WSL update and reinstall guide:

While you CAN use WSL on earlier Windows 10 releases [prior to Windows 10 Fall Creators Update (version 1709)], this beta "legacy distro" is now considered obsolete. We strongly encourage you to run the most recent version of Windows 10 available.

If you installed WSL some time ago, especially if it was prior to version 1709, a simple uninstall and re-install through the Microsoft Store might help you. For those with this problem on the current version (1803 as of now), I have no answer for you.


Fully uninstall legacy WSL and re-install

Note: While enabling the WSL feature or when installing WSL through the Store, it might be a good idea to turn off programs that might interfere with WSL (@Johnno suggested Acronis True Image which I had running during previous attempts).

  1. Uninstall legacy WSL with Powershell:

    lxrun /uninstall /full
    

    Make sure there are no leftover files:

    rm -Recurse $env:localappdata/lxss/
    
  2. Disable WSL from "Turn Windows features on or off" or by using Powershell:

    Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    

    Reboot.

  3. Update Windows 10

  4. Enable WSL again from "Turn Windows features on or off" or by using Powershell:

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    

    Reboot.

  5. Download WSL through the Microsoft Store. Search for 'Ubuntu', click install.

  6. After installation, first reboot. Don't start WSL yet (e.g. do not click on 'launch' in the Store or call WSL from the command line).

  7. After reboot, open Powershell and type ubuntu. Set up your distro (guide here).

Solution 2

I had a similar issue. The root cause was because I had created a junction for my user profile so the application would install from Windows, but however the system is passing those strings within the WSL, it does not interpret junction points.

Is the lxss file system located at it's literal location (e.g. C:\users\USERNAME\AppData\Local\lxss is actually there and not junctioned to a different drive or path?

Common causes of this would be alternatively defined user profile path or a hardlink/junction made with mklink.exe.)

Share:
6,879

Related videos on Youtube

Lucubrator
Author by

Lucubrator

Interested in Python.

Updated on September 18, 2022

Comments

  • Lucubrator
    Lucubrator over 1 year

    When trying to create user accounts in Bash on Ubuntu on Windows 10 I receive: Creating UNIX user failed, returned error code 10.

    When entering bash I get the message groups: cannot find name for group ID 0.

    I am thus stuck with the default root user. I have tried reinstalling to no avail.


    I have tried the following (in the cmd prompt with admin privileges):

    lxrun /uninstall /full
    lxrun /install /y    
    lxrun /setdefaultuser MyUsername
    

    When trying to add users I get:

    groupadd: failure while writing changes to /etc/group
    adduser: `/usr/sbin/groupadd -g 1000 MyUsername' returned error code 10. Exiting.
    Creating UNIX user failed, this can be done later by running lxrun.exe /setdefaultuser
    

    I also tried to add users from within bash (entering using the bash command in Powershell) as suggested by @CodeIt, without success.

    • Admin
      Admin almost 7 years
      After installing bash, you could log in to your bash by typing bash. Then you can set the default user.
    • Admin
      Admin almost 7 years
      I added an edit to the question about your sollution. Unfortunately, it didn't work. Did I do it correctly?
    • Admin
      Admin almost 7 years
      You were right. But it seems there is a problem with your WSL installation. Uninstall using lxrun /uninstall /full and the reinstall using lxrun /install /y then i should work.
    • Admin
      Admin almost 7 years
      As you see in my original question, I have already tried that. Or are you saying that it might work this time? If so why? I have tried uninstalling with lxrun /uninstall /full and I've also tried to remove WSL from the "Turn Windows features on or off" list, in addition to doing a full uninstall. Doing the same steps on my other computer results in a working installation.
    • Admin
      Admin almost 7 years
      Are you able to open /etc/group ? What do you see ?
    • Admin
      Admin almost 7 years
      I did root@DESKTOP-AAB3FS:~# cd /etc/ and then root@DESKTOP-AAB3FS:/etc# cd groupand I get bash: cd: group: No such file or directory /etc/group seems to be missing.
    • Admin
      Admin almost 7 years
      I do however have -rw------- 1 root 0 596 Mar 30 08:53 group- and -rw-r--r-- 1 root 0 609 May 20 21:29 group+.
  • Lucubrator
    Lucubrator almost 6 years
    At the time I wrote the question I think I actually had Acronis True Image installed, so that could have been the problem. Currently I am on another computer, running Win 10 Pro together with Acronis True Image. The newest version of WSL (downloaded from the Microsoft store) have been working flawlessly so far.
  • Lucubrator
    Lucubrator almost 6 years
    I did have a alternatively definer user profile path at the time. I was never able to fix the problem on that computer and I therefore took a long break from WSL. Recently, I gave it another chance (WSL from the Microsoft store), and since I haven't encountered any problems.
  • Ramhound
    Ramhound over 5 years
    At what point did you enable the feature, that’s still required, even with 1709+?
  • Lucubrator
    Lucubrator over 5 years
    @Ramhound I think it was just after 1703, but it might have been prior to that.