linux 忘记密码解决方法,Linux 忘记密码解决方法

本文以Fedora Core (2.6.18.3) 为例说明用单用户模式删除root密码的方法

前 提:grub没有设置密码

1. 单用户模式启动系统

启动进入grub列表界面时,选择Linux启动项,按e键编辑内核启动参数

root (hd0,7)

kernel /boot/vmlinuz-2.6.18.3 ro root=LABEL=/ vga=0x303 rhgb quiet

initrd /boot/initrd-2.6.18.3.img

选择kernel /boot/vmlinuz-2.6.18.3 ro root=LABEL=/ vga=0x303 rhgb quiet 行,按e编辑修改为 kernel /boot/vmlinuz-2.6.18.3 ro 1 root=LABEL=/ vga=0x303 rhgb quiet这样做目的是使系统以单用户模式启动,Linux系统共有6种启动模式

# Default runlevel. The runlevels used by RHS are:

#   0 - halt (Do NOT set initdefault to this)

#   1 - Single user mode

#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)

#   3 - Full multiuser mode

#   4 - unused

#   5 - X11

#   6 - reboot (Do NOT set initdefault to this)

编辑完后,回车,然后按 b键启动系统

2.删除配置文件中的密码字段的内容

与用户相关的配置文件主要有 passwd,shadow,group三个文件,其中用户密码在shadow文件中

这三个文件都在/etc目录下

用VI 编辑/etc/shadow文件,此文件内容如下

root:$1$/btfNd/X$cIVRZzqfy..M1aBxeUMaZ.:13667:0:99999:7:::

bin:*:13667:0:99999:7:::

daemon:*:13667:0:99999:7:::

adm:*:13667:0:99999:7:::

lp:*:13667:0:99999:7:::

sync:*:13667:0:99999:7:::

shutdown:*:13667:0:99999:7:::

halt:*:13667:0:99999:7:::

mail:*:13667:0:99999:7:::

news:*:13667:0:99999:7:::

uucp:*:13667:0:99999:7:::

operator:*:13667:0:99999:7:::

games:*:13667:0:99999:7:::

gopher:*:13667:0:99999:7:::

ftp:*:13667:0:99999:7:::

nobody:*:13667:0:99999:7:::

rpm:!!:13667:0:99999:7:::

dbus:!!:13667:0:99999:7:::

avahi:!!:13667:0:99999:7:::

rpc:!!:13667:0:99999:7:::

mailnull:!!:13667:0:99999:7:::

smmsp:!!:13667:0:99999:7:::

nscd:!!:13667:0:99999:7:::

vcsa:!!:13667:0:99999:7:::

haldaemon:!!:13667:0:99999:7:::

rpcuser:!!:13667:0:99999:7:::

nfsnobody:!!:13667:0:99999:7:::

sshd:!!:13667:0:99999:7:::

netdump:!!:13667:0:99999:7:::

pcap:!!:13667:0:99999:7:::

xfs:!!:13667:0:99999:7:::

beaglidx:!!:13667:0:99999:7:::

ntp:!!:13667:0:99999:7:::

apache:!!:13667:0:99999:7:::

hsqldb:!!:13667:0:99999:7:::

tomcat:!!:13667:0:99999:7:::

gdm:!!:13667:0:99999:7:::

其中第一行root:$1$/btfNd/X$cIVRZzqfy..M1aBxeUMaZ.:13667:0:99999:7::: 中的第二个字段内容就是root用户的密码,将此字段内容删除,修改后为 root::13667:0:99999:7:::

保存文件

3.重新启动系统,输入用户名root,回车后直接进入系统

此方法在Redhat9也试过

(victor_tlh)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值