一、设置root账户的密码
在win10上,安装了 Ubuntu20.04 的子系统,但是sudo密码 忘记了,需要找回:
- ①:管理员权限启动
PowerShell; - ②:
ubuntu2004 config --default-user root - ③:打开
Ubuntu子系统 输入passwd,设置新的root密码,两次设置; - ④:然后关闭
Ubuntu子系统,但是每次打开默认是root用户。
二、出现的问题
安装Ubuntu 子系统时,最初创建的普通用户是greamrod(自定义创建的普通账户),可以看到如下信息:
greamrod@DESKTOP-0M2GP7V:/mnt/f$ iduid=1000(greamrod) gid=1000(greamrod) groups=1000(greamrod),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),117(netdev),1001(docker)greamrod@DESKTOP-0M2GP7V:/mnt/f$greamrod@DESKTOP-0M2GP7V:/mnt/f$ pwd/mnt/fgreamrod@DESKTOP-0M2GP7V:/mnt/f$ ls -lls: 'System Volume Information': Permission deniedtotal 0drwxrwxrwx 1 root root 4096 May 12 14:22 '$RECYCLE.BIN'drwxrwxrwx 1 root root 4096 Jun 15 21:24 RuoYi-Vued--x--x--x 1 root root 4096 May 12 15:20 'System Volume Information'drwxrwxrwx 1 root root 4096 May 26 21:18 data_structure_codedrwxrwxrwx 1 root root 4096 Jun 3 21:09 greamrod-codedrwxrwxrwx 1 root root 4096 May 12 14:34 temp_codedrwxrwxrwx 1 root root 4096 Jun 13 22:33 web-codegreamrod@DESKTOP-0M2GP7V:/mnt/f$
现在,经过第一步重置root后,每次打开默认是 root 用户!而且获取不到/mnt/f目录下的任何信息:
root@DESKTOP-0M2GP7V:/mnt/f$ iduid=0(root) gid=0(root) groups=0(root)root@DESKTOP-0M2GP7V:/mnt/f$ pwd/mnt/froot@DESKTOP-0M2GP7V:/mnt/f$ ls -ldrwxrwxrwx 1 root root 4096 Jun 15 21:14 .drwxr-xr-x 9 root root 4096 May 12 16:31 ..
三、解决方案
- ①:再次 在
PowerShell中,执行,ubuntu1804 config --default-user greamrod(也可以使用userID就是刚才的默认一般用户) -
四、参考文章:
WSL ubuntu18.04忘记/找回root密码:[https://blog.csdn.net/qq_37299249/article/details/100673367](https://blog.csdn.net/qq_37299249/article/details/100673367)为新的Linux分发版创建用户帐户和密码:[https://docs.microsoft.com/zh-cn/windows/wsl/user-support](https://docs.microsoft.com/zh-cn/windows/wsl/user-support)
