织梦CMS - 轻松建站从此开始!

罗索

Linux 忘记密码解决方法

落鹤生 发布于 2010-05-05 15:22 点击:次 
前提:grub没有设置密码,以Fedora Core (2.6.18.3) 为例说明用单用户模式删除root密码的方法
TAG:

本文以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种启动模式

  1. # Default runlevel. The runlevels used by RHS are: 
  2. #   0 - halt (Do NOT set initdefault to this) 
  3. #   1 - Single user mode 
  4. #   2 - Multiuser, without NFS (The same as 3, if you do not have networking) 
  5. #   3 - Full multiuser mode 
  6. #   4 - unused 
  7. #   5 - X11 
  8. #   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)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201005/9335.html]
本文出处:百度博客 作者:victor_tlh
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容