三三世界-百宝箱

文章 分类 标签
130 9 247

公告

暂无站点公告

Centos7重置root用户密码

三三 2022-05-28 1270 0条评论 Linux使用 linux centos7重设密码

首页 / 正文

Centos 7如果忘记密码,有单用户和光盘两种方式修改。具体如下:

一、单用户模式修改密码:

1、启动的时候,可以按“上或者下”键盘,以免直接进入系统,在启动界面内核条目上,选择相应启动项,内核名称上按“e”;

2、进入后,找到linux16开头的地方,按“end”键到最后,输入rd.break,按ctrl+x进入;

3、进去后输入命令mount,发现根为/sysroot/,并且不能写,只有ro=readonly权限;

4、重新挂载输入命令:

mount -o remount,rw /sysroot/

之后mount,发现有了r,w权限;

5、输入命令改变根:

chroot /sysroot/

(1)echo redhat|passwd –stdin root 修改root密码为redhat,或者输入passwd,交互修改;推荐用passwd命令直接修改密码。

(2)还有就是先cp一份,然后修改/etc/shadow文件

6、touch /.autorelabel 这句是为了selinux生效

7、ctrl+d 退出

8、然后reboot

二、光盘启动方式

当系统无法启动,甚至无法进入单用户时,可通过安装光盘引导进入救援模式,对系统进行修复。
a).把机器设置为光盘启动。

第一种方法:F2进入BIOS设置 BOOT---"CD-ROM Drive"为第一引导项。用上下箭头移动到CD-ROM上,再按“+” 上移目标到第一项,最后按F10 保存配置退出重启。自动进入光盘引导。

第二种方法:开机后,快按一下ESC,出现CD-ROM引导界面,用上下键头选择CD-ROM后回车进入光盘引导。

b).光盘引导进入

(1)出现下图时选择第三项"troubshooting" 然后按回车键。
(2)下面页面输入"1" 选 continue
(3)进入系统然后输入下面命令可更改root密码:

chroot /mnt/sysimage/
passwd root
exit

经验证,两种方式均可实现重置密码,但前提条件是能拿到本机。

评论(0)

当前没有评论,还不快来留下第一个脚印吧


Copyright 2021 三三世界-百宝箱. All Rights Reserved.

最新评论

  • 三三

    @Doug Shume it's ok for me , you can post here.

  • refugiaguenther

    Saved as a favorite, I like your website!

  • josefa

    If some one wishes to be updated with hottest technologies after that he must be visit this site and be up to date daily.

  • Penzu

    Heello would you mind sharing which blog platform you're using? I'm planning to start my own blog in the near future but I'm having a tough time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then moost blogs and I'm looking for something completely unique. P.S Apologies forr being off-topic butt I had to ask!

  • Yupoo Fendi

    Thanks to my father who shared with me regarding this webpage, this website is genuinely amazing.

  • Doug Shume

    Hi, I have an overflow of customers that I'd like to send to you but I want to make sure you can handle more leads, let me know if you'd like me to send you more info.

  • SuperWind

    zh.us.to 有效
    kms.03k.org 有效
    kms.chinancce.com
    kms.shuax.com 有效
    kms.dwhd.org 有效
    kms.luody.info 有效
    kms.digiboy.ir 有效
    kms.lotro.cc 有效
    www.zgbs.cc 有效
    cy2617.jios.org 有效

  • 三三

    @         权限问题,试试sudo 再加命令。

  •         

    你好提示Permission denied 怎么办啊

日历

2024年05月

   1234
567891011
12131415161718
19202122232425
262728293031 

文章目录

上一张 下一张