linux用户账号新建,为 Linux 分发版创建用户帐户 | Microsoft Docs

为新的 Linux 分发版创建用户帐户和密码Create a user account and password for your new Linux distribution

05/12/2020

本文内容

启用 WSL 并从 Microsoft Store 中安装 Linux 分发版后,在打开新安装的 Linux 分发版时将会要求你完成的第一步是创建帐户,包括 用户名 和 密码。Once you have enabled WSL and installed a Linux distribution from the Microsoft Store, the first step you will be asked to complete when opening your newly installed Linux distribution is to create an account, including a User Name and Password.

此 用户名 和 密码 特定于安装的每个单独的 Linux 分发版,与 Windows 用户名无关。This User Name and Password is specific to each separate Linux distribution that you install and has no bearing on your Windows user name.

创建 用户名 和 密码 后,该帐户将是分发版的默认用户,并将在启动时自动登录。Once you create a User Name and Password, the account will be your default user for the distribution and automatically sign-in on launch.

此帐户将被视为 Linux 管理员,能够运行 sudo (Super User Do) 管理命令。This account will be considered the Linux administrator, with the ability to run sudo (Super User Do) administrative commands.

在适用于 Linux 的 Windows 子系统上运行的每个 Linux 分发版都有其自身的 Linux 用户帐户和密码。Each Linux distribution running on the Windows Subsystem for Linux has its own Linux user accounts and passwords. 每当添加分发版、重新安装或重置时,都必须配置一个 Linux 用户帐户。You will have to configure a Linux user account every time you add a distribution, reinstall, or reset.

13d83e016ae487ab7b4a73673a9bf71e.png

更新和升级包Update and upgrade packages

大多数分发版随附了一个空的的包目录或最简单的包目录。Most distributions ship with an empty or minimal package catalog. 我们强烈建议定期更新包目录并使用分发版的首选包管理器升级已安装的包。We strongly recommend regularly updating your package catalog and upgrading your installed packages using your distribution's preferred package manager. 对于 Debian/Ubuntu,请使用 apt:For Debian/Ubuntu, use apt:

sudo apt update && sudo apt upgrade

Windows 不会自动更新或升级 Linux 分发版。Windows does not automatically update or upgrade your Linux distribution(s). 大多数 Linux 用户往往倾向于自行控制此任务。This is a task that most Linux users prefer to control themselves.

重置 Linux 密码Reset your Linux password

若要更改密码,请打开 Linux 分发版(例如 Ubuntu)并输入以下命令:passwdTo change your password, open your Linux distribution (Ubuntu for example) and enter the command: passwd

系统会要求你输入当前密码,然后要求输入新密码,之后再确认新密码。You will be asked to enter your current password, then asked to enter your new password, and then to confirm your new password.

忘记密码Forgot your password

如果忘记了 Linux 分发版的密码:If you forgot the password for your Linux distribution:

请打开 PowerShell,并使用以下命令进入默认 WSL 分发版的根目录:wsl -u rootOpen PowerShell and enter the root of your default WSL distribution using the command: wsl -u root

如果需要在非默认分发版中更新忘记的密码,请使用命令:wsl -d Debian -u root,并将 Debian 替换为目标分发版的名称。If you need to update the forgotten password on a distribution that is not your default, use the command: wsl -d Debian -u root, replacing Debian with the name of your targeted distribution.

在 PowerShell 内的根级别打开 WSL 发行版后,可使用此命令更新密码:passwd ,其中 是 DISTRO 中帐户的用户名,而你忘记了它的密码。Once your WSL distribution has been opened at the root level inside PowerShell, you can use this command to update your password: passwd where is the username of the account in the DISTRO whose password you've forgotten.

系统将提示你输入新的 UNIX 密码,然后确认该密码。You will be prompted to enter a new UNIX password and then confirm that password. 在被告知密码已成功更新后,请使用以下命令在 PowerShell 内关闭 WSL:exitOnce you're told that the password has updated successfully, close WSL inside of PowerShell using the command: exit

备注

如果运行的是早期版本的 Windows 操作系统,例如 1703(创意者更新)或 1709 (Fall Creators Update),请参阅此用户帐户更新文档的存档版本。If you are running an early version of Windows operating system, like 1703 (Creators Update) or 1709 (Fall Creators Update), see the archived version of this user account update doc.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值