Linux single-user mode to reset root password

Linux single-user mode to reset root password

Text Keywords: Linux, run the system-level, single-user mode, forget the root password, change password

First, the system run level

1. Linux system boot process

To enter into single-user mode, we must first look at system boot process, we confirm what step to start with. Only by understanding the real master, farewell rote.
Linux single-user mode to reset root password

  • Power: For a virtual machine is to click the Run button.
  • BIOS self-test: This step is mainly a variety of scanning, and the confirmation method starts guide, such as a hard disk, an optical disk, network and the like.
  • grub boot menu: If you already have an operating system that works properly on the hard disk, it will enter the boot menu. This step is critical for us, because then the next step will be to start loading the kernel init process, then according to the specified run level to run the system, if we want to change the temporary start level system into single-user mode, you must to operate this step in the boot menu.
  • Load the kernel: The system reads the relevant files in the / boot directory, the core loading system
  • init process: initialization process for initializing the system environment
  • Determining an operating level: The level at a given operating configuration of the system
  • User login: Enter the user name and password to log in
  • Execute the logon script: According to the script of the user's profile information to perform a user login (user management will be further described in the article)

    2. Related Profiles

  • /boot/grub/grub.conf:grub boot menu configuration file

You can modify the configuration file countdown countdown boot menu, the corresponding configuration item: timeout.
Start menu may be arranged in the encrypted file, the corresponding configuration item: password. (Single-user encryption will be described in the article)

  • / Etc / inittab: configuration and behavior of each operation under the command level, it can also be used to modify the default operating system level

SUMMARY configuration file format is as follows:
ID: The runlevels: Action: Process
ID for the custom name, the only requirement in the paper, and no more than four characters in length.
runlevels scope consistent with the operating system level, you can specify multiple.
action represents behavior at a given level to be executed, a fixed value. The default configuration after running level specified for the system start: initdefault.
process section specifies the specific command to be executed, when the initdefault action is specified, the portion may be omitted.

3. Run level List

Direct use of the content / etc / inittab do the control of
Linux single-user mode to reset root password

  • 0: Shutdown
  • 1: single-user
  • 2: Multi-user (non-NFS)
  • 3: Full multi-user mode
  • 4: No Use
  • 5: the graphical interface
  • 6: Restart

    4. The default run level

    If you need to modify the default run level as long as the configuration file to modify any original line number that corresponds to the target level. Such as: change the default operating level by the graphical interface is fully multi-user mode, then changed to 5 3.

    # 原始内容 id:5:initdefault:
    id:3:initdefault:

    Second, the single-user mode to reset the password

  • Press any key to boot into the grub menu countdown

Linux single-user mode to reset root password

Linux single-user mode to reset root password

  • The prompt to enter edit interface according to e

Linux single-user mode to reset root password

  • The second option: the kernel, continue to edit e

Linux single-user mode to reset root password

Linux single-user mode to reset root password

  • End of the input: [space] 1 [ENTER]

Linux single-user mode to reset root password

  • Back to the menu screen, press the start b

Linux single-user mode to reset root password

  • After the boot will enter the single-user mode, you can directly use the passwd command to reset the root password

Linux single-user mode to reset root password
The password is entered, the cursor will not produce any change is a normal phenomenon, after the completion of the transport can be input

  • Password changes are complete reboot command reboot, the system will re-enter the default level before running

Guess you like

Origin blog.51cto.com/10984944/2462602