I am currently using Arch Linux on WSL2, and I am new to it. In the previous time, I mostly used Ubuntu 18.04 on VMWare. I switch to Arch Linux and WSL2 is because I want to explore something new, and I learned from others that Arch is an interesting Linux distribution.
After installing Arch on WSL2, I added a new user called gwen
and set the password, using the following commands:
[root@DESKTOP-ROOSFVQ ~]# useradd -m gwen
[root@DESKTOP-ROOSFVQ ~]# passwd gwen
New password:
Retype new password:
passwd: password updated successfully
After that, I used pacman -S vim
to install thie vim
editor.
When using Ubuntu, I set the user gwen
when installation. I mostly log in as the user gwen
, and it creates a directory for gwen
. When I want to install some packages by apt
, I use sudo apt install xxx
. When I need some superuser permission, I add sudo
before the command. But I mostly operate under the default user gwen
.
So this time, I set the default user as gwen
in the /etc/wsl.conf
and restart the system. When the terminal is reopened, the default user changes to gwen
indeed. The configuration in /etc/wsl.conf
likes this:
[user]
default=gwen
But after that, when I want to install Git
using pacman -S git
, it reports an error
[gwen@DESKTOP-ROOSFVQ ~]$ pacman -S git
error: you cannot perform this operation unless you are root.
I know that there's no permission for user gwen
to install packages, so I tried to switch back to user root
.
[gwen@DESKTOP-ROOSFVQ ~]$ su
Password:
su: Authentication failure
There's no password for root when Arch Linux is installed. I have never set any password for it neither. So when entering password, I just press the Enter
, and it says authentication failure. I also try the gwen
password either, but it also says authentication failure.
I search for some similar questions, they say it could be solved by entering sudo su
, I try it either, but it says sudo: command not found
:
[gwen@DESKTOP-ROOSFVQ ~]$ sudo su
bash: sudo: command not found
Now I don't know what to do, can you give me some advice on how to solve it?
I am not sure, but it seems that sudo
is not installed by default on Arch Linux and your user gwen
is not in the sudo
ers group.
You could try:
1. Exit WSL
completely
2. Open Windows Command Prompt and run: wsl -u root
3. This will log you back as root
4. Then run bash
pacman -S sudo
usermod -aG wheel gwen
5. Exit and restart WSL
, after that, gwen
should be able to use sudo
.
Alternative: you could also set a root
password with passwd
while you are root
.