zoukankan      html  css  js  c++  java
  • Resetting the Root Password Using rd.break for RHEL7

    • Start the system and, on the GRUB 2 boot screen, press the e key for edit.
    • Remove the rhgb and quiet parameters from the end, or near the end, of the linux16 line, or linuxefi on UEFI systems.

      Press Ctrl+a and Ctrl+e to jump to the start and end of the line, respectively. On some systems, Home and End might also work.

    IMPORTANT

    The rhgb and quiet parameters must be removed in order to enable system messages.

     

    • Add the following parameters at the end of the linux line on 64-Bit IBM Power Series, the linux16 line on x86-64 BIOS-based systems, or the linuxefi line on UEFI systems:

     

    rd.break enforcing=0

     

    Adding the enforcing=0 option enables omitting the time consuming SELinux relabeling process.

    The initramfs will stop before passing control to the Linux kernel, enabling you to work with the root file system.

    Note that the initramfs prompt will appear on the last console specified on the Linux line

    • Press Ctrl+x to boot the system with the changed parameters.

      With an encrypted file system, a password is required at this point. However the password prompt might not appear as it is obscured by logging messages. You can press the Backspace key to see the prompt. Release the key and enter the password for the encrypted file system, while ignoring the logging messages.

       

      The initramfs switch_root prompt appears.

       

    • The file system is mounted read-only on /sysroot/. You will not be allowed to change the password if the file system is not writable.

      Remount the file system as writable:

      switch_root:/# mount –o remount,rw /sysroot

    • The file system is remounted with write enabled. Change the file system's root as follows:

     

    switch_root:/# chroot /sysroot

     

    The prompt changes to sh-4.2#.

     

    • Enter the passwd command and follow the instructions displayed on the command line to change the root password.

       

      Note that if the system is not writable, the passwd tool fails with the following error:

       

      Authentication token manipulation error

       

    • Updating the password file results in a file with the incorrect SELinux security context. To relabel all files on next system boot, enter the following command:

      sh-4.2# touch /.autorelabel

      Alternatively, to save the time it takes to relabel a large disk, you can omit this step provided you included the enforcing=0 option in step 3.

    • Remount the file system as read only:

      sh-4.2# mount –o remount,ro /

    • Enter the exit command to exit the chroot environment
    • Enter the exit command again to resume the initialization and finish the system boot.s

      With an encrypted file system, a password or phrase is required at this point. However the password prompt might not appear as it is obscured by logging messages. You can press and hold the Backspace key to see the prompt. Release the key and enter the password for the encrypted file system, while ignoring the logging messages.

    NOTE

    Note that the SELinux relabeling process can take a long time. A system reboot will occur automatically when the process is complete.

     

    • If you added the enforcing=0 option in step 3 and omitted the touch /.autorelabel command in step 8, enter the following command to restore the /etc/shadow file's SELinux security context:

       

      # restorecon /etc/shadow

       

      Enter the following commands to turn SELinux policy enforcement back on and verify that it is on:

       

      # setenforce 1

      # getenforce

      Enforcing

       

     

     

     

  • 相关阅读:
    CentOS6.5(1)----设置静态IP并禁用IPV6
    CentOS7运维管理笔记(12)----修改主机名
    重温C语言(1)----计算算术表达式的值
    C++学习笔记(9)----关于变量和数组大小的一道容易出错的面试题
    MySQL数据库(13)----忘记root用户密码解决方案【转载】
    C++学习笔记(8)----C++类的大小
    C++学习笔记(7)----类的数组中构造函数和析构函数的调用顺序
    C++学习笔记(6)----基类和派生类的构造函数和析构函数的执行顺序
    switch的参数类型
    windows下双击可运行的Java软件打包方案(转)
  • 原文地址:https://www.cnblogs.com/cqubityj/p/6900871.html
Copyright © 2011-2022 走看看