Pengwin
Pengwin copied to clipboard
Unable to set default user after importing
Describe the bug A clear and concise description of what the bug is.
Unable to set the default user to run as when opening Pengwin.
I
To Reproduce
Steps to reproduce the behavior:
In order to run pengwin-setup, you are told to run the default user. This is normally fine but if you export the distro and import it on another machine, your default user becomes root. You can create a normal user with sudo access but when attempting to set the config to use that user as the default, it fails to do so. Based on WSL documentation, you should be able to something like debian config --default-user username. In this case, I expect wlinux or pengwin to replace debian.
Expected behavior A clear and concise description of what you expected to happen.
I expect the default user to change and verified when Pengwin was opened again.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Basic Troubleshooting Checklist
[x] I have searched Google for the error message. [x] I have checked official WSL troubleshooting documentation: https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#confirm-wsl-is-enabled. [x] I have searched the official Microsoft WSL issues page: https://github.com/Microsoft/WSL/issues. [x] I have searched the Pengwin issues page: https://github.com/WhitewaterFoundry/Pengwin/issues. [ ] I have reset Pengwin: Settings->Apps->Apps & features->Pengwin->Advanced Options->Reset. N/A [ ] I have disabled and re-enabled WSL in Windows Features. [x] I have run Windows 10 updates and restarted.
What other troubleshooting have you attempted?
Insert here:
Pengwin Version
Find: Settings->Apps->Apps & features->Pengwin->Advanced Options->Version.
Insert here: N/A but was exported from the latest release in the Store.
Windows Build
Run 'systeminfo | findstr /C:"OS"' in Command Prompt and insert here: 10.0.18363 N/A Build 18363
For help on retrieving: https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#check-your-build-number
Hello,
If you imported in the same directory as the default directory of the Pengwing installation, you can use the executable pengwin.exe as you described.
If you imported in another directory, it is basically a exe less distribution so you need to change it in another way inside the built-in WSL support. Go to RegEdit.exe and look for your imported distribution:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\guid\DefaultUid and change its value by (usually) 1000.
Regards, Carlos
So I did a comparison to another distro and added a few entries including setting the UID to 1000. However doing this returned the original user it was exported from. I don't want to use the old user in this case. I want a different user. Thoughts on changing this for default?
This number is the user number in Linux:
$ id user
uid=1000(user) gid=1000(user) groups=1000(user),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev)
Yes, I resolved the issue. What I had to do was in CMD or PS (I used PS7):
wsl -s Pengwin (I renamed it on import to Pengwin)
wsl --exec sudo useradd username add user
wsl --exec sudo usermod -aG sudo username adds new user to sudoers
wsl --exec sudo passwd username
Then exit wsl session.
wsl --terminate Pengwin
wsl -u username
id #gives you current UID/GID
sudu su
userdel oldusername
usermod -u 1000 <LOGIN> #NewUid
groupmod -g 1000 <GROUP> #NewGID
find / -user <OLDUID> -exec chown -h 1000 {} \;
find / -group <OLDGID> -exec chgrp -h 1000 {} \;
usermod -g 1000 <LOGIN>
Exit WSL and re-enter. You should now automatically log in with the new user as default. Bear in mind there will a number of "permission denied" for anything under /mnt/c when fixing the permissions and ownerships of the Linux directories.
Also credit to https://muffinresearch.co.uk/linux-changing-uids-and-gids-for-user/ for most of these steps
Re-opened since it has feature-enhancement tag. If this can be done automatically by pengwin by detecting it's on a different host (or a duplicate on the same host), that would be optimal.
Yes, I think we can do something at our side this is why I marked it Feature Enhancement.
Thank you for reopening, I didn't realize that was closed.
Hello,
We made a release 20.10.2 that automatically fills the [user] section of wsl.conf when the user is created and each time that the user is changed via pengwin config --default-user. Then when you --export and then --import the default user will remain.
Regards, Carlos
Great I'll be sure to test it out. This should be one of those things you add to Raft to use for other distros under the pengwin-setup stuff.
Yes, or automatically after install.
Raft already saves the information of the default user with the backup and restores it. This time using registry instead of wsl.conf for any distro.
It is a good improvement