• RedHat/Centos修改root密码


            Linux主机忘记密码,只要你能接触物理主机都可以修改root密码的!

      Redhat6.x 5.x  / Centos6.x  5.x

    01、开机-空格/enter

    02、e-编辑模式

    CentOS 6.4和RHEL6.X 单用户模式找回密码,启动的时候,提示“输入任何键进入菜单(英文好像是: press any key to enter menu)”,这时回车或空格

    出现:    “CentOS (2.6.32-358.e16.i686)”  菜单。
    下面有提示:输入'e' to edit the commands before booting.

    因此,我们输入 'e'字符,接着的界面会有3个选项出现:
        root (hd0,0)
        kernel /vmlinuz-...
        initrd /initramfs...

     我们选择中“kernel ...”这一行,然后按下"e"键,这时提示:
        <BOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet

    后面追加 空格+single 等价 1
    在这行的末尾输入 " single" (注意,single前面有个空格),回车,
    这将回到3个选项的那个界面(这时第二项依旧处于选中状态),然后按下 'b',以此选项启动Linux

    然后等待,操作系统启动完成,期间不需要输入密码!命令行显示为:
    [root@]#
    现在我们可以以root身份执行命令了。

    passwd

    修改密码:

    (a) 对于CentOS 6.4 我们可以用"passwd"命令修改密码!
    (b) 对于RHEL 6.x,"passwd"命令无效!
    我们执行命令:
    echo 'ybxiang123' | passwd --stdin root
    密码就改成了'ybxiang123'

    然后用 "init 6" 重启! / reboot


    Redhat7.x  / Centos7.x

    1. 重启redhat7,上下 e(编辑)
    e ----------> linux16    末尾添加
    物理机: rd.break
    虚拟机: rd.break console=tty0

    ctrl + x  继续

    switch_root:/# mount -o rw,remount /sysroot
    switch_root:/# chroot /sysroot
    sh-4.2# passwd root
    sh-4.2# touch /.autorelabel    //SELinux开启的情况下
    sh-4.2# exit
    switch_root:/# reboot

    参考文档:

    http://www.linuxidc.com/Linux/2014-09/106446.htm

  • 相关阅读:
    在Ubuntu/Centos使用 Let's Encrypt 证书部署 HTTPS的方法
    Ubuntu14.04安装配置LAMP环境(php5.6)
    centos6 php5.4 升級到php 5.6
    为自己的2017年定个计划
    收益的一些话
    学习瓦力部署系统的项目配置和上线部署
    统计进仓和出仓数量随时间变化的剩余数量流程图
    Codeigniter 获取当前的控制器名称和方法名称
    [记]Windows 系统下设置Nodejs NPM全局路径
    [记]Cordova安装插件选择插件版本
  • 原文地址:https://www.cnblogs.com/xiaochina/p/5699251.html
Copyright © 2020-2023  润新知