Solutions to common problems in Linux systems

巴扎黑
Release: 2017-08-10 11:28:43
Original
2222 people have browsed it

[Introduction] Under Windows systems, when some system failures occur, we will use some common remedial measures to repair the system. Under Linux systems, there are also some commonly used measures to solve common failures. Use them It is also more convenient. First of all, we need to establish a rescue disk group, including preparation

Under Windows systems, when the system fails, we will use some common remedial measures to repair the system. There are also some under Linux systems The more commonly used measures to solve common faults are also relatively convenient to use.

First we need to create a rescue disk group, including two floppy disks, bootdisk and rootdisk, which can provide an independent support for starting and running a complete Linux system. If you are a system administrator, then this is definitely an essential daily maintenance tool for you. The first disk in the rescue disk group stores the bootable kernel program system of the Linux system, and the second disk in the rescue disk group contains a complete Linux system, including the "root" file system.

Using the emergency disk group to maintain the system is relatively simple to operate. When starting the system, you need to use these two disks to start the system so that you can enter the emergency mode. At this time, we use the "root" account. But in order to access the files already on the hard disk, we need to manually install the hard disk's file system. The root directory of the system now refers to the root directory on the rescue disk. In order to access the files in the hard disk file system, you must first install the files into a directory specified by you. In this way, if the file system on the hard disk is installed in the /mnt directory, the path of the original /etc/passwd file on the hard disk is /mnt/etc/passwd. For example, use the following command to install the ext2fs Linux file system on the /dev/hda2 disk in the /mnt directory: # monut -t ext2/dev/hda2/mnt.

The most common mistake we make may be accidentally deleting some important files, and they cannot be restored directly. However, if there is a corresponding file in the rescue disk group, we can find this file from the rescue disk group and copy it to the hard disk. For example, if the file /bin/login is deleted, the system will not be able to enter the login interface normally. We can first start the system with the rescue disk group, install the hard disk file system to the /mnt directory, and then use the following command :

#cp -a /bin/login /mnt/bin
Copy after login

The "-a" option is used to tell "cp" to maintain file access permissions when copying files. Of course, if the deleted basic files are not in the rescue disk group, this method cannot be used. But if you have done a backup of the system before, you can use the previous backup to restore it.

It is also common for the file system to be damaged. If you are using an "ext2fs" type file system, we can run the "e2fsck" command from the floppy disk to repair the damaged file system. For other types of file systems, the corresponding "fsck" command can be used. A common cause of file system corruption is damage to the file system's "header" (also known as the "superblock"), which contains information such as the file system's status, size, and free disk blocks. If the "header" of a file system is damaged, the system may not recognize the file system at all, so it cannot be mounted. Even the "e2fsck" command cannot handle this problem. However, the "ext2fs" type of file system backs up the contents of the "superblock" and stores it at the driver's block group boundary. You can use the following command to tell "e2fsck" to use the backup of the super block:

# e2fsck -b 8193 <partition>
Copy after login

If you accidentally damage the system function library file, or damage the symbolic link in the /lib directory, it will cause dependence on these libraries. The command cannot be executed normally. The simplest solution is to restart the system with a rescue disk set, install the hard disk file system in the /mnt directory, and then repair the libraries in the /mnt/lib directory.

If the super user forgets his password, he will not be able to enter the system, manage and use the system. Using a rescue disk set can solve the problem. If the password may have been changed by a hacker, causing the system administrator to be unable to enter the system normally, that is to say, the Linux system has completely lost control, so control of the system should be regained as soon as possible. The usual solution is to format the hard drive and reinstall the system, but this is a bit of a fuss. Prepare two floppy disks, bootdisk and rootdisk, boot from the floppy drive, boot to the "root" disk and the "shell" prompt appears. "Mount" the Linux root directory partition to the /mnt directory. For example, if your Linux is on the first partition of the hard disk, enter mount /dev/hda1 /mnt in the command line, then enter the mnt directory and rename the etc/passwd file in it. , enter mv /mnt/etc/passwd /mnt/etc/passwd.bak; then use the command cp /etc/passwd /mnt/etc/passwd to copy the /etc/passwd file on the floppy disk to the " etc" directory, restart from the hard disk, and the super password will not be asked when logging in; finally use the mv/etc/passwd.bak passwd command to change the passwd file back, and then run the passwd command to reset the password. System administrators should change passwords from time to time to prevent long-term use of one number from being stolen by others.

在个人计算机使用Linux系统时,通常都是Linux和MS Windows 9x或MS Windows NT等并存的。由于安装了其他的操作系统,经常会导致原有的Linux系统不能正常启动。这主要是因为,这些操作系统默认为计算机中没有其他的操作系统,因而改写了硬盘的主引导记录(MBR),冲掉了Linux的LiLo系统引导程序。

如果有急救盘组,当然很简单,可以用第一张启动盘启动硬盘的Linux系统,重新运行LiLo命令,就可以将LiLo系统引导程序写回硬盘的主引导记录,重新启动机器即可。但是如果没有制作系统启动盘,没有急救盘组如何恢复硬盘上的Linux系统呢?在这种情况下,如果知道Linux系统在硬盘上的确切安装分区,且有loadlin程序,就可以重新返回Linux系统。 loadlin程序是在DOS下运行的程序,运行它可以从DOS下直接启动Linux系统。在 Red Hat Linux 6.0光盘的 DOSutil/目录下就有这个程序。除此之外,还需要一个 Linux启动内核的映像文件。在 Red Hat linux 6.0光盘的 images/目录下有这个文件--vmlinuz。 例如,在Windows 98系统下,进入DOS的单用户模式,然后运行下述的loadlin命令,即可重新进入Linux系统:

loadlin vmlinuz root=/dev/hda8
Copy after login

其中“/dev/hda8”是Linux系统的“root”文件系统所在的硬盘分区位置。命令执行后,就引导Linux系统用“root”登录后,运行LiLo命令,则可以重新将LiLo装入MBR,至此就可以回到以前多操作系统并存使用的状态了。

也许你不是一个系统管理员,但是随着个人计算机配置的日益提高,在自己的计算机上安装Linux系统已经不是什么新鲜的事了。假设我们的计算机上同时装有Windows和Linux两个操作系统,应该如何启动Linux呢?是否每次都需要重启计算机,通过LiLo引导?其实如果我们在DOS下,有一种简单快速启动Linux的方法,那就是Load Linux。“loadlin.exe”是在DOS下的可执行程序,它可以在纯DOS环境下迅速启动Linux,而且无需重启计算机,通常我们可以在光盘的/kernels目录下找到这个程序。如果不知这个程序被放置于安装盘的何处,可以使用“find -name loadlin*”命令来寻找。找到之后将其复制到DOS分区中,同时还需要复制一份你所使用的Linux内核文件。可以通过Windows直接从光盘复制,也可在Linux环境下使用mcopy命令将文件copy到DOS分区;接着再编写一个Linux.bat的批处理文件,文件内容如下:

c:loadlin c:vmlinuz root=/dev/hda1 ro
Copy after login

其中我们假设loadlin.exe和vmlinuz这两个内核文件都在c盘根目录,而root为Linux根设备,而且Linux处于硬盘第一分区,所以设备名为/dev/hda1,ro意为readonly。以后在DOS下要启动Linux时,运行Linux.bat就可以了。这样启动Linux快速高效,大大减少了系统自检时等待的时间。

如果我们在Xwindows状态下运行Linux时,由于硬件本身的问题或者自己操作上的不当,有时侯可能会导致系统突然失去响应,也就是我们常见到的一种死机现象,其实此时系统并没有死机。我们可以用两个常用的方法来消除这种现象:第一,用键盘上的复合键Ctrl+Alt+Backspace来关闭当前正在运行的任务;第二,首先按住键盘上的Ctrl+Alt+F2复合键,让系统切换到另一个操作台,然后登录到系统,再执行#ps -ax|grep startx命令,这将会列出你的Xserver的进程标识(PID),接着在命令行中输入如下命令就能消除Xwindows下的死机现象:#kill -9 PID_Number,最后通过Alt+F1复合键返回原来的平台。

常见的错误及解决办法还有很多,在这里只是提及了一部分,如果大家还有需要补充的或是本文中有需要纠正的地方欢迎提出,让我们一起提高。


The above is the detailed content of Solutions to common problems in Linux systems. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!