# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hezhiqiang.gitbook.io/about-the-author/linux-xi-tong-gu-zhang-pai-cha/linux-xi-tong-zhong-zhi-mi-ma-fang-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
