6 emergency handling tips in the Linux operating system

  

1. Using a rescue disk set for maintenance
A rescue disk set (also known as a boot/root disk group) is an essential tool for system administrators. Use it to start and run a complete Linux system independently. In fact, the second disk in the rescue disk group has a complete Linux system, including the root file system; and the first disk holds the bootable kernel.
Using a rescue disk set to maintain the system is simple. Just use these two disks to boot the system and enter the rescue mode, which is the root account. In order to access files on the hard disk, you need to manually install the hard disk file system. For example, use the following command to install the ext2fs type Linux filesystem on the /dev/hda2 disk in the /mnt directory: < mon> -t ext2/dev/hda2/mnt
Note: The root directory is now The root directory on the rescue disk. In order to access files in the hard disk file system, you must first install it in a directory. Thus, if the file system on the hard disk is installed in the /mmt directory, the path to the original /etc/passwd file on the hard disk is /mnt/etc/passwd
2. When the file system is corrupted
When the file system is destroyed, if you use the ext2fs type file system, you can use the e2fsck command from the floppy disk to correct the corrupted data in the file system. For other types of file systems, the corresponding fsck command can be used. When checking the file system from a floppy disk, it is best not to mount the
Note: A common cause of file system corruption is that the super block is corrupted. The super block is the file system's "head". It contains information such as the state, size, and free disk blocks of the file system. If you damage a file system's super block (for example, if you accidentally write data directly to the file system's super block partition), the system may not recognize the file system at all, so you can't install it, even with the e2fsck command. I can't handle this problem either.
However, the ext2fs type of file system backs up the contents of the superblock and stores it in the driver's block group boundary. You can use the following command to notify e2fsck to use the super block backup
# e2fsck -b 8193
is the partition where the file system is located, and the -b 8193 option is used to display the super block using the 8193 block stored in the file system. Backup data
3. Recover lost files
If you accidentally delete important files, there is no way to recover them directly. However, you can also copy the corresponding files from the rescue disk to the hard disk. For example, if the file /bin/login is deleted, the system cannot enter the login interface normally. You can use the rescue disk group to boot the system, install the hard disk file system to the /mnt directory, and then use the following command:
# Cp -a /bin/login /mnt/bin
The “-a” option is used to tell cp to keep access to files when copying.
Of course, if the deleted basic file is not in the "first aid disk group", you can not use this method. If you have done a system backup before, you can also use the previous backup to restore.
4. Handling methods when the library is destroyed
If you accidentally destroy the system library file, or destroy the symbolic link in the /lib directory, then the commands that depend on these libraries will not be executed. The easiest solution is to boot the system with the rescue disk set, install the hard disk file system in the /mnt directory, and then repair the libraries in the /mnt/lib directory.
5. Unable to log in to the system as root account
Due to the negligence of the system administrator or the system being compromised by the hacker, the system administrator may not be able to log in to the system with the root account.
For the first case, it may be that the system administrator has forgotten the root password and can solve the problem with the rescue disk group.
For the second case, since the password is likely to be modified by the hacker, the system administrator cannot enter the system, that is, the Linux system completely loses control, so the system should be regained control as soon as possible. After obtaining root privileges, you should also check the system for damage, in case it is hacked again.
The main job that needs to be done is to reset the root password and gain control of the Linux operating system. First boot the system with the rescue disk set, then install the file system of the hard disk to the /mnt directory, edit the /mnt/etc/passwd file, and empty the line of the encrypted password field corresponding to the root account, as shown below:
root::0:0:root:/root:bin/bash
Note: If the system uses the shadow tool, you need to do the above operation on the file /etc/shadow so that the root login system does not require a password.
This way, the root account has no password. When you restart the Linux system from the hard disk, you can log in with the root account (the system does not ask for a password). After entering the system, use the command passwd to set a new password.
6. Linux system can't start
Generally speaking, if the system administrator can't enter the system normally, you need to consider using the rescue disk group to enter the emergency mode to troubleshoot the system. But if the Linux system cannot be started without creating a rescue disk set, what should I do?
When using a Linux system on a personal computer, Linux and MS Windows 9x or MS Windows NT are usually coexisting. Due to the reinstallation of other operating systems, it often causes the original Linux to fail to start. This is mainly because these operating systems default to no other operating system on the computer, thus overwriting the hard disk's master boot record (MBR), flushing out the Linux LILO system bootloader.
If there is a rescue disk set, it is very simple, use the first boot disk to boot the hard disk Linux system, re-run the LILO command, you can write the LILO system boot program back to the hard disk master boot record. Turn it on again.
If there is no system boot disk, how to recover Linux on the hard disk? In this case, if you know the exact installation partition of Linux on the hard disk and there is a loadlin program, you can return to Linux. The loadlin program is a program under DOS. Run it to boot Linux directly from DOS and quickly enter the Linux environment. This program is available in the dosutil/directory of the Red Hat Linux 6.0 CD. In addition to this, you need an image file for the Linux boot kernel. This file ——vmlinuz is available in the images/directory of the Red Hat linux 6.0 CD.
For example, under Windows 98 system, enter the single-user mode of DOS, and then run the following loadlin command to re-enter the Linux system:
loadlin vmlinuz root=/dev/hda8
/dev/Hda8 is the hard disk partition location where the Linux root file system is located. After the command is executed, the Linux system is booted. After logging in as root and running the LILO command, LILO will be loaded into the MBR again, returning to the state where multiple operating systems were used together.

Copyright © Windows knowledge All Rights Reserved