win10 linux for subsystme ubuntu 修改默认用户和密码方法

All other answers were helpful, but can be other scenarios too, follow here as per yours. Mine was ubuntu 1604, so use following:-

ubuntu1604 config --default-user

if you installed ubuntu 1804:-

ubuntu1804 config --default-user

if you used default one, then:-

ubuntu config --default-user

之所以登录:google 了一下午找到答案。 安装的是ubuntu1604版本,网上使用的“ubuntu config --default-user ”运行一直报错如下:


ubuntu : 无法将“ubuntu”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径
正确,然后再试一次。
所在位置 行:1 字符: 1
+ ubuntu config --default-user
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (ubuntu:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException”

终于找到正确答案。

原因:
ubuntu安装时会提示设置用户名和密码,这样root的密码就是随机的。需要将root用户设置为默认账户,并设置密码后 才可以正常使用su和sudo。

  • 如何查看ubuntu 子系统的账户和密码?

账户和密码保存在%userprofile%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu16.04onWindows_79rhkp1fndgsc\LocalState\rootfs\etc 文件下 shadow 和shadow- 文件中。

win10 linux for subsystme ubuntu 修改默认用户和密码方法