从文件导入的 wsl 发行版如何更改默认用户 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wdssmq
V2EX    分享发现

从文件导入的 wsl 发行版如何更改默认用户

  •  
  •   wdssmq 2022-05-24 20:34:06 +08:00 1643 次点击
    这是一个创建于 1241 天前的主题,其中的信息可能已经有所发展或是发生改变。

    从应用商店安装时创建了用户,导入后则默认是 root 用户,想切换回去;

    # 从文件导入 wsl --import Ubuntu "C:\wsl\Ubuntu" "D:\#bak\WSL\wsl-2022-05-24.tar" # 查看列表 wslconfig /l # Ubuntu-18.04 (默认) # Ubuntu # 可以执行,但是好像没效果 ubuntu1804 config --default-user wdssmq # 也试过切换默认后执行上边命令 wslconfig /setdefault Ubuntu # 会提示不存在 # ubuntu config --default-user wdssmq 

    最后尝试停用其他的项只留要修改的好像就可以了?

    wsl -l -v # NAME STATE VERSION #* Ubuntu Running 2 # Ubuntu-18.04 Running 2 # wsl --shutdown wsl -t Ubuntu-18.04 wsl -l -v # NAME STATE VERSION #* Ubuntu Running 2 # Ubuntu-18.04 Stopped 2 ubuntu1804 config --default-user wdssmq 

    严格来说不清楚生效的是哪个方案,因为我同时设置了/etc/wsl.conf

    [在 wsl 发行版内部]

    [user] default=wdssmq 

    windows subsystem for linux - Change default WSL 2 user after export/import - Super User

    https://superuser.com/questions/1602502/change-default-wsl-2-user-after-export-import

    windows subsystem for linux - how to change the default user after import old wsl tar package? - Stack Overflow

    https://stackoverflow.com/questions/61474401/how-to-change-the-default-user-after-import-old-wsl-tar-package

    Set Default User for Windows Subsystem for Linux Distro in Windows 10 | Tutorials

    https://www.tenforums.com/tutorials/128152-set-default-user-windows-subsystem-linux-distro-windows-10-a.html

    1 条回复    2022-05-24 23:44:42 +08:00
    cxxlxx
        1
    cxxlxx  
       2022-05-24 23:44:42 +08:00   1
    Note this new restored distribution will login as root so you need to change the registry key to the default UUID of 1000.

    First open the registry by hittingWindows Button + R, then type in regedit and hit return. This should open up the registry. Next move to the folder`aHKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss`

    Now look down the list of registry entries in there and see which one matches the name you gave your distribution. Then go to the DefaultUid and change this to decimal 1000 not hexidecimal as this will not work.

    Next time you launch your restored WSL setup it should start normally with your usual setup rather than as root.

    按照这个
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2984 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 13:07 PVG 21:07 LAX 06:07 JFK 09:07
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86