> For the complete documentation index, see [llms.txt](https://hezhiqiang.gitbook.io/about-the-author/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hezhiqiang.gitbook.io/about-the-author/linux-xi-tong-gu-zhang-pai-cha/linux-xi-tong-zhong-zhi-mi-ma-fang-fa.md).

# Linux 系统重置密码方法

#### 博客作者：联系请[点击](https://hezhiqiang.gitbook.io/about-the-author/lian-xi-zuo-zhe)，搬运不易，希望请作者喝咖啡，可以点击[联系博客作者](https://hezhiqiang.gitbook.io/about-the-author/lian-xi-zuo-zhe)

## 前言

例如，root口令遗忘、丢失等，那么可以让机器启动进入单用户状态来从新设置设置。

## 操作步骤：

#### &#x20;1、  重启系统，在开机过程中，出现以下界面时按`e`键，进入编辑界面。

![](/files/-MaUoK_NO6TDbOrRum0M)

#### 2、 按方向键下键`↓`，找到设置语言的地方，如`LANG=en_US.UTF-8`，在后面追加`rw single init=/bin/bash`,然后按`ctrl+x`重启系统

![](/files/-MaUqJ0HylHU8htXCsJd)

#### 3、 进入bash界面后，可以输入`passwd`命令重新设置root密码

![](/files/-MaUtNwT6ihgzbjWj-ce)

#### 4、 如果开启了SELinux，执行命令`touch /.autorelabel`命令； 5、 输入`exec /sbin/init`命令重启系统； 6、 使用新设置的密码进入系统之后，为了安全起见，可以输入`reboot`重新启动一次系统

![](/files/-MaUu0-OuI6hh3QdGQ8I)
