![]() ![]() See the answers to this question for additional details. If you've already created the user, or are using a different distribution, as points out, make sure to also add the user either to a group that is in sudoers or directly to sudoers via visudo. Then set the user as the default using the /etc/wsl.conf as mentioned above. I have added a new user, and confirmed that this new user had to be added to the group sudo before being able to use sudo. The root user does have a password on the account. Useradd -create-home -shell /usr/bin/bash -user-group -groups adm,dialout,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev -password $(read -sp Password: pw echo $pw | openssl passwd -1 -stdin) $NEWUSER I still have sudo access and can switch to the root user unrestricted. Under Ubuntu, the default distribution for WSL, you can create your user by starting with: wsl ~ -u root This can happen when the distribution installation is stopped prematurely, and likely for other reasons as well. 1 sudo passwd -u root Now you can log in as a root account via the su command below and use the whoami command to verify the user. Some users who find this answer may be starting up as root not because they -import'd a distribution, but possibly because the default user was never created during installation in the first place. 1 sudo passwd root Now you can enter a new password and then proceed to use the -u command option with the command to unlock the root user. My belated apologies! Here's the additional information based on advice. If su doesn't seem to be working, check if it has the setuid bit set. Two other users have now mentioned in the comments that information was helpful. 1 su is already a setuid binary, so it must be able to switch to any user which you demand it to, with proper authentication. You can check the name by going to "Manage app execution aliases" in the Windows System Settings.įor readers who need to create a new made a good point in the comments last year that I, in hindsight, dismissed improperly. exe here is an "App Execution Alias" in Windows. exe config -default-user įor instance, if you installed "Ubuntu 20.04" from the Store, you would use: ubuntu2004.exe config -default-user ![]() However, for completeness, you can also set the default username for a distro that was installed from the Store (or wsl -install) with. Side Note: This question was specifically about setting the default username in an imported instance. Wsl -u username or wsl -d distroname -u username, etc. The username can be selected when starting any WSL instance by: Semi-method 4 - Runtime user selection via wsl commandline argument ![]() Do you really need sudo On debian I always logon as root so have no. Ultimately this has the same effect as Method 2. Maybe sudo isnt installed Open your package manager and install the sudo package. Using LxRunOffline to set the registry entry, as described in answer. This is safer and less error-prone than the registry-based methods. When you restart, the default user should be set. The current Microsoft recommended way of setting the username in an instance is to create a /etc/wsl.conf in the instance with the following setting: Ĭhanging, of course, username to be your default username.Įxit your distro/instance, then issue a wsl -terminate from PowerShell or CMD. While the two that have already been mentioned still work, there is a Microsoft recommended way to do it that hasn't been mentioned yet in this question. Note: This opens the /etc/sudoers file using your default editor.As of the time of this writing, there are at least three (let's call it 3.5) different methods of changing/setting the default user in an imported WSL instance. To configure it run either of the commands below: sudo nano /etc/sudoers ![]() The no password requirements is configured in the /etc/sudoers file. To fix this you need to be able to run sudo for that specific user with no password requirements. As it can’t find a tty, sudo falls back to an askpass method but can’t find an askpass command configured, so the sudo command fails. The issue is caused by executing a sudo command which tries to request for a password, but sudo does not have access to a tty to prompt the user for a passphrase. The remote script failed with exit code 1 (The starting of unprivileged containers by the root user is possible, but not described here. However when I run the command I get the error: sudo: no tty present and no askpass program specified Basic usage LXC can be used in two distinct ways - privileged, by running the lxc commands as the root user or unprivileged, by running the lxc commands as a non-root user. I was trying to run a sudo command from a remote machine to deploy an app to the server. I faced this issue when working on an Ubuntu 20.04 server. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |