<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Password on HiDa</title><link>https://www.0niu.cn/tags/password/</link><description>Recent content in Password on HiDa</description><generator>Hugo -- gohugo.io</generator><language>zh</language><lastBuildDate>Mon, 26 Feb 2018 21:58:46 +0800</lastBuildDate><atom:link href="https://www.0niu.cn/tags/password/index.xml" rel="self" type="application/rss+xml"/><item><title>重置Windows中Linux子系统用户密码</title><link>https://www.0niu.cn/posts/reset-the-user-password-of-wsl/</link><pubDate>Mon, 26 Feb 2018 21:58:46 +0800</pubDate><guid>https://www.0niu.cn/posts/reset-the-user-password-of-wsl/</guid><description>&lt;p>Windows10应用商店提供了Linux子系统，可以直接安装，省得自己弄虚拟机了，很是方便。平时都是直接命令行直接进入，不用输入密码，今天需要提升权限却发现密码忘记了。因为是子系统，所以与正常重置密码操作有些不同。大致原理就是：&lt;/p>
&lt;ol>
&lt;li>
&lt;p>切换默认登录用户为root&lt;/p>
&lt;/li>
&lt;li>
&lt;p>登录root（不用输入密码），重置用户密码&lt;/p>
&lt;/li>
&lt;li>
&lt;p>切换回原来使用的用户&lt;/p>
&lt;/li>
&lt;/ol>
&lt;p>之前的操作方法是：&lt;/p></description><content>&lt;p>Windows10应用商店提供了Linux子系统，可以直接安装，省得自己弄虚拟机了，很是方便。平时都是直接命令行直接进入，不用输入密码，今天需要提升权限却发现密码忘记了。因为是子系统，所以与正常重置密码操作有些不同。大致原理就是：&lt;/p>
&lt;ol>
&lt;li>
&lt;p>切换默认登录用户为root&lt;/p>
&lt;/li>
&lt;li>
&lt;p>登录root（不用输入密码），重置用户密码&lt;/p>
&lt;/li>
&lt;li>
&lt;p>切换回原来使用的用户&lt;/p>
&lt;/li>
&lt;/ol>
&lt;p>之前的操作方法是：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#在Windows上用管理员权限打开 CMD 或者 PowerShell（win+x，A） 修改默认登录用户为 root ：&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>lxrun /setdefaultuser root
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#现在登录打开 WSL 直接就是 root 登录，并不需要密码&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#修改用户密码&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>passwd your_username
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#将默认登录用户由 root 修改回普通用户&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>lxrun /setdefaultuser your_username
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>我装的是Ubuntu，报错&lt;code>警告: lxrun.exe 仅用于配置适用于 Linux 的 Windows 子系统的旧分发版。可以通过访问 Windows 应用商店来安装分发版&lt;/code>
后来发现可以通过下面命令更改登录用户&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>ubuntu config --default-user your_username
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h4 id="参考文档">参考文档&lt;/h4>
&lt;p>&lt;a href="https://askubuntu.com/questions/772050/reset-the-password-in-linux-bash-in-windows">Reset the Password in Linux Bash in Windows&lt;/a>&lt;/p></content></item></channel></rss>