Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux CD Rescue Mode clear root password

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Linux CD Rescue Mode clear root password

Text keywords: Linux, CD rescue mode, forget root password, clear root password

The CD rescue mode is mainly used when the system is damaged and can be used to manually repair or copy critical data. But because you can use root permissions for limited operations in this mode (most commands cannot be used because the system is not loaded), we can also clear the root user's password if you forget your password. CD rescue mode is mainly suitable for physical machines, and when entering single-user mode is encrypted and forgets the password (well, it's bad enough).

1. Linux user information file 1. Configuration file path / etc/passwd

The information about the user recorded in the configuration file will be written when the user is successfully created, and subsequent changes will be recorded in the file, which only root users have the right to modify by default.

two。 Column meaning: use colons to separate the first column: user name second column: password placeholder, x means password authentication is required after the use, empty does not need a password third column: user ID (ordinary users from 500th column) fourth column: main user group ID fifth column: user additional information sixth column: user home directory location seventh column: user login execution shell3. Determine the starting position

Once we know the location of the configuration file, all we need to do is find a way to clear the password of the root user. That is, after entering the shell in rescue mode, edit the user information file and delete the x placeholder in the second column. Restart the system after saving and exiting, and you no longer need a password to log in using root users again.

Second, CD-ROM rescue mode

For disks that have installed the operating system, if the system can boot normally, then we need to modify the boot sequence in the BIOS settings to ensure that we boot from the CD and enter the CD menu.

1. CD image mount related files: Linux image file

If it is a virtual machine, mount the image file directly. If it is a real physical machine, you can burn the image file to a U disk.

Since we need to enter the motherboard (BIOS) to set up, we need to shut down the virtual machine as it was when it was first installed, enter the virtual machine configuration interface, and mount the CD.

Make sure to check the connection at startup, choose to use IOS image file, and correctly select the path of IOS image file.

After selecting the virtual machine, click: virtual machine-> Power-> enter the firmware when you turn on the power

Switch to the Boot tab

Adjust the CD boot (CD-ROM Drive) to the first item: operate with plus or minus sign

Press F10 to save and restart, you can enter the CD boot interface, and the third is the rescue mode.

two。 Enter rescue mode to select language and keyboard (although there is an option in Chinese, it still doesn't seem to support it)

After selecting the language, the network selection interface appears. If you do not need the network, you can choose: No

3. Select continue to mount the disk directory. If you only want to view it, select Read-Only.

According to the prompt, the files on the disk have been mounted to the / mnt/sysimage directory. You can modify the root directory location through the chroot secret order, otherwise you need to add the / mnt/sysimage path as a prefix when manipulating the files.

Open a shell environment and proceed to the next step

Clear the root password 1. Modify password file

The bash environment can be used directly in CD rescue mode, and the permission identifier is an exciting pound sign, yes, super permissions! But there is still a difference, at this time, we did not enter the previous Linux system, so do not use the passwd command to directly change the password, is not allowed, to modify the user profile to achieve.

Vi / mnt/sysimage/etc/passwd removes the second column password placeholder for the first line root user

Shut down after saving and exiting if you want to enter the system, you need to enter BIOS again to modify the boot sequence poweroff boot to firmware and adjust CD-ROM Drive to its original position.

Press F10 to save and exit to enter the system normally, the first startup will take a long time, wait patiently for 2. 5%. Resolve unwritable

If you are prompted to be read-only and not writable when you modify the file, first make sure that Continue is selected instead of Read-Only when mounting. If there is still a problem, then we can remount the problem.

Mount-o remount,rw / mnt/sysimage/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report