47 lines
1.0 KiB
Markdown
47 lines
1.0 KiB
Markdown
> 本文作者:丁辉
|
|
|
|
# Centos重置Root密码
|
|
|
|
1. 重启服务器在选取内核界面按 `e`
|
|
|
|
<img src="https://minio.offends.cn:9000/offends/images/image-20240706142021741.png">
|
|
|
|
2. 找到以 `linux16` 开头的行添加如下内容
|
|
|
|
<img src="https://minio.offends.cn:9000/offends/images/image-20240706142326298.png">
|
|
|
|
3. 按 `Ctrl+x` 保存
|
|
|
|
4. 进入系统后执行挂载 / 文件系统
|
|
|
|
```bash
|
|
mount -o remount, rw /
|
|
```
|
|
|
|
<img src="https://minio.offends.cn:9000/offends/images/image-20240706142853583.png">
|
|
|
|
5. 重置密码(密码不能过于简单)
|
|
|
|
```bash
|
|
passwd root
|
|
```
|
|
|
|
<img src="https://minio.offends.cn:9000/offends/images/image-20240706143013863.png">
|
|
|
|
6. 创建此文件让系统启动全盘的 SELinux 上下文重新标记
|
|
|
|
```bash
|
|
touch /.autorelabel
|
|
```
|
|
|
|
<img src="https://minio.offends.cn:9000/offends/images/image-20240706143459451.png">
|
|
|
|
7. 重启 init 进程让系统恢复到正常的多用户运行级别
|
|
|
|
```bash
|
|
exec /sbin/init
|
|
```
|
|
|
|
8. 登录新密码测试
|
|
|
|
|