Switching between root and normal users in WSL2

1: First, if you are using ubuntu of window stores of window11, first open a command window,

enter:

 ubuntu2204 config --default-user root

This will switch to root login

2: Open ubuntu2204 of wsl2, now you are the root user of root, here you can reset your user password

As follows: passwd xxxx (username); later you can reset your user password

3: Switch to normal user again

ubuntu2204 config --default-user 普通用户名

Then you open the ubuntu of wsl2, which is the authority of ordinary users. You can use sudo to perform operations with root privileges

Note: ubuntu2204 is the system name plus version number

Guess you like

Origin blog.csdn.net/qq960685827/article/details/129114710