Linux Basics and Applications

Source: Internet
Author: User
Tags command line file system require reset

1, processing the special file name

Assuming that there is a file named "-aaa" in the Linux system, if we want to do it, for example, now to delete it, if we enter the RM-AAA command on the command line according to the general deletion method, the interface will prompt us to be invalid (invalid option), Because the first character of the filename is--Linux uses the filename as an option, we can use the "--" notation to solve the problem, such as we can enter RM---AAA command to delete the-aaa file. If you have other special characters, you can add a "" symbol before the special character, or enclose the entire file name in double quotes.

2, repair Linux under the Super User's password

If the Superuser forgets the password, it will not be able to access the system or manage and use the system. This is not likely to happen, but in some Linux stand-alone users, especially beginners, it is relatively easy to happen. The general solution is to format the hard drive to reinstall the system, but that's a bit of a fuss. Prepare the Bootdisk and Rootdisk two floppy disks, boot from the floppy drive, boot to the root disk and a shell prompt appears. Mount the Linux root partition to the/mnt directory, such as your Linux on the first partition of the hard disk, enter mount/dev/hda1/mnt on the command line, then enter the MNT directory, rename the etc/passwd file, and enter mv/mnt/etc/ Passwd/mnt/etc/passwd.bak on it; then use the command cp/etc/passwd/mnt/etc/passwd to copy the/etc/passwd file on the floppy disk to the ETC directory on your hard disk so that you can restart the hard drive. When you log on, you will not ask for a super password, and then use the Mv/etc/passwd.bak passwd command to change the passwd file back, then run the passwd command to reset the password.

3, directly to install the Linux work

Normally, when installing an operating system software, the boot disk of the system is required to be installed. But when we install the Linux operating system, we can take advantage of a DOS software called Loadlin.exe in the system CD, direct the Linux core into memory, and replace the Linux core with the current operating system to take over the computer and go into the Linux installation interface. When installing Linux, we simply enter Loadlin E:imagesvmlinuz Root=/dev/ram in the Run dialog box initrd=e:imagesinitrd.img This command to install Linux directly, where E is the optical drive letter, E:imagesvmlinuz is the Linux core name.

4. Start Linux system quickly

With the increasing configuration of personal computers, installing Linux on your own computer is nothing new. Suppose we have Windows and Linux two operating systems installed on our computers, how do I start Linux? Do I need to reboot the computer every time, through Lilo? In fact, if we are in DOS, there is a simple and quick way to start Linux, that is load Linux. Loadlin.exe is an executable program in DOS that can quickly start Linux in a pure DOS environment without restarting the computer, and usually we can find this program in the/kernels directory of the CD. If you do not know where the program is placed on the installation disk, you can use the "find-name loadlin*" command to find it. When you find it, copy it to a DOS partition, and you'll need to copy the Linux kernel file you're using. Can be copied directly from the CD through Windows, or you can copy the file to a DOS partition using the Mcopy command in a Linux environment, and then write a linux.bat batch file with the following file: C:loadlin c:vmlinuz Root=/dev /HDA1 ro

We assume that Loadlin.exe and Vmlinuz are both kernel files in the C-packing directory, while Root is the Linux root device, and Linux is in the first partition of the hard disk, so the device name is/dev/hda1,ro meaning readonly. Later in DOS to start Linux, run Linux.bat on it. This allows Linux to start quickly and efficiently, greatly reducing the time it waits for the system to self-test.

 5, eliminate the xwindows under the crash phenomenon

If we run Linux in the Xwindows state, because of the hardware itself or the improper operation, sometimes may cause the system suddenly lost response, that is, we often see a panic phenomenon, in fact, the system did not panic. We can use two commonly used methods to eliminate this phenomenon: first, with the keyboard of the composite key ctrl+alt+backspace to close the current running tasks; second, first hold down the keyboard ctrl+alt+f2 composite key, let the system switch to another console, and then log into the system, Then execute the #ps-ax|grep startx command, which will list your Xserver process identity (PID), and then enter the following command on the command line to eliminate the Xwindows panic: #kill-9 Pid_number, and finally through ALT + The F1 composite key returns to the original platform.

6, fast shutdown Linux system

The older version of the Linux/unix system must run the shutdown command before power is turned off, but the latest version of the Linux/unix system has been greatly improved in this respect and there is no need to shut down as before. Because the new version of the system borrowed from the mainframe technology, the use of power-off log-type file system, can automatically track the preservation of user data, automatic synchronization of the file system, users can easily turn off the power supply, so as to quickly shut down the purpose of the system.

7. Use RM command skillfully

We know that in the Linux character interface, to delete a file can use the RM command, delete a directory can use the RmDir command. However, because the rmdir command can only delete a blank directory, if a directory has a file, you can only use the RM command to delete the files in the directory, so you usually need to rmdir and RM the two commands in conjunction with the use to completely delete a complete directory. But in this way to deal with a few subdirectories can do, if a directory contains a number of subdirectories, and the number of subdirectories contains a number of subdirectories, and then use this method does not take you tired of the blame. We can now use the RM command with the-r parameter to delete a non-empty directory, such as we enter rm-r BBB at the command line, indicating that all files and subdirectories contained in the BBB directory will be deleted.

8, the use of Virtual Console

When we log into the Linux system, and then click the ALT+F2 key on the keyboard, then we can see a shell prompt, in fact, this is the second Virtual Console. In general, the newly installed Linux system has four Virtual Console, we can use the composite keys ALT+F1, ALT+F2, ALT+F3, alt+f4 to access them respectively. The most Frequently used Virtual Console is when a program locks in the input or the Linux system suddenly loses its response, you can switch to other Virtual Console login to kill this error process task.

9, increase the virtual cache

If there is not enough swap (swap space) on the computer, as long as we have free space on our hard drive, we can use the rest of the space, we can direct the command: Mkswap/dev/hda (assuming the Linux drive is/dev/hda), Swapon/ Dev/hda, to automatically start swap, you can add the new partition to the Etc/fstab, according to the original swap write on the line. With "free" check the size of swap, Linux supports up to 16 swap partitions, each swap partition maximum 128M, no idle partitions, you can use a large file to build. The following is a series of commands executed:

#dd If=/dev/zero of=swapfile bs=1024 count=8192

#mkswap Swapfile 8192


#swapon Swapfile

10. Use the TAB key skillfully

We know that in the Linux character interface input commands, sometimes need to enter a lot of characters, if it is often so one by one to enter characters, more cumbersome. Assuming that the characters you type are sufficient to determine the next unique file in the directory, we simply press the TAB key on the keyboard to automatically complement the rest of the file name, for example, to unpack the files under the directory/CCC when we type ddddddd-1.2.3.tar.gz to the tar xvfz in the command line CCC/D, if the file is the only file in this directory that starts with D, you can press the TAB key directly on the keyboard, and the command is automatically padded with the following: Tar xvfz/ccc/ddddddd-1.2.3.tar.gz, which improves the efficiency of the input.

 11, more use copy and paste to improve operating speed

Linux system after installation, each boot to the character interface will automatically run a program called GPM, the program can be run after the mouse to copy and paste. The practice is to hold down the left mouse button to make copies of the place highlighted, when the highlighted area has been copied, and then the right mouse button copy content will be pasted at the cursor location. If we run the Linux system under Xwindow, the copy and paste operation is the same as under the normal Win9x system.

12, speed up Linux access to data

If we want to quickly improve the hard drive reading data under Linux, you can set up some settings under Linux to allow Linux to work in 32-bit input and output mode and DMA channel mode. When setting, enter the command/sbin/hdparm-cl/dev/hda in the Linux command interface to turn on the 32bit transmission mode, enter the command/sbin/hdparm-dl/dev/hda to turn on the DMA transfer mode, and then enter the command/sbin/ Hdparm-kl/dev/hda make the hard drive still maintain the above settings after reset, through these settings, we can improve the Linux read disk speed to more than 1 time times.

13, the use of emergency disk Group for maintenance

The first Aid disk group (also known as the Boot/root Disk group) is an essential tool for system administrators. It allows you to start and run a complete Linux system independently. In fact, there is a complete Linux system on the 2nd disk of the first aid disk group, including the root file system, while the 1th disk holds the bootable kernel.

It is easy to use the first Aid Disk group maintenance system. Just use these two disks to start the system, enter the first aid mode, then use the root account. In order to access the files on your hard disk, you need to manually install the hard disk file system. For example, use the following command to install the EXT2FS type of Linux file system on the/DEV/HDA2 disk in the/MNT directory:

# monut-t Ext2/dev/hda2/mnt

Note: The root directory is now the root directory on the first aid disk. In order to access files in the hard disk file system, you must first install it into a directory. This way, 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.

 14, the file system is destroyed when the processing method

When the file system is corrupted, if you are using a EXT2FS type of file system, you can modify the corrupted data in the file system from the floppy disk transport e2fsck command. For other types of file systems, you can use the appropriate fsck command.

When you check the file system from a floppy disk, it is best not to mount it.

Note: The common cause of file system corruption is that the super block is corrupted and the Super block is the "head" of the file system. 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, accidentally writing data directly to the file system's Super block partition), the system may not be able to recognize the file system at all, so you can't install it, even with the e2fsck command.

However, the EXT2FS type of file system backs up the contents of the Super block and resides in the driver's block group boundary. You can notify e2fsck to use a backup of a super block with the following command

# E2fsck-b 8193

Refers to the partition where the file system resides, and the-B 8193 option is used to display the backup data that uses the 8193 blocks that are stored in the file system.

15, recover the lost files

If you accidentally delete an important document, there is no way to recover it directly. However, you can also copy the appropriate files from the first aid disk to your hard disk. For example, if you delete the file/bin/login, the system does not normally go to the login interface, you can start the system with the first Aid disk group, install the hard disk file system into the/MNT directory, and then use the following command:


The "-a" option is used to tell the CP to maintain access to files while copying. Of course, if the deleted basic file is not in the "First Aid disk group", this method can not be used. If you have previously done a system backup, you can also use the previous backup to restore.

4. The processing method when the function storehouse destroys

If you accidentally destroy the system library files or destroy the symbolic links in the/lib directory, the commands that depend on these libraries will not execute. The simplest solution is to start the system with the first Aid disk group, install the hard disk file system in the/mnt directory, and then repair the library under the/mnt/lib directory.

16, unable to use the root account login system

The system administrator may not be able to log on to the system with the root account because of the negligence of the system administrator or because the system is hacked by hackers.

For the 1th case, the system administrator may have forgotten the root password, and the problem can be solved by using the first Aid disk group.

In the 2nd case, because the password is likely to be modified by hackers, so the system administrator can not access the system, that is, the Linux system is completely out of control, so should regain control of the system as soon as possible. After you obtain root permissions, you should also check the system for damage to prevent the hacker from invading again.

The main task that needs to be done is to reset the root password to gain control of the Linux operating system. First use the first Aid disk group to start the system, and then install the hard disk file system to the/mnt directory, edit the/mnt/etc/passwd file, it corresponds to the root account of a line of encryption password domain empty, as follows:


Note: If the system uses the shadow tool, you need to do this for the file/etc/shadow, so that the root login system does not require a password.

In this way, the root account will have no password. When you restart the Linux system from the hard drive, you can log in with the root account (the system does not require a password). After entering the system, use the command passwd to set the new password.

17, Linux system can not start

In general, if the system administrator does not enter the system properly, you need to consider using the first Aid disk group into the first aid mode to troubleshoot the system. But what if the Linux system does not boot without making the first aid disk group?

When a personal computer uses a Linux system, it is usually compatible with Linux and MS Windows 9x or MS Windows NT.

Due to the reinstallation of other operating systems, it often causes the original Linux to not start. This is mainly because these operating systems default to no other operating system on the computer, overwriting the hard drive's master boot Record (MBR), and flushing out the Linux Lilo system boot.

If you have a first aid disk group, it is simple to start the Linux system on the hard drive with the first boot disk and rerun the Lilo command to write the Lilo system boot back to the master boot record on your hard disk. Reboot again.

If there is no system boot disk, how to restore Linux on the hard drive? In this case, if you know that Linux is on the hard disk to install the exact partition, and there are loadlin programs, you can return to Linux. Loadlin program is a DOS program, run it can start Linux directly from the DOS, quickly into the Linux environment. This program is available in the dosutil/directory of the Red Hat Linux 6.0 CD. In addition, a Linux boot kernel image file is required. In Red H

At the images/directory of the Linux 6.0 CD has this file--vmlinuz.

For example, under the 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 location of the hard disk partition where the Linux root file system resides. After the command is executed, the Linux system is booted. When you log in with root, run the Lilo command, then reload the Lilo into the MBR, back to the same state as the previous multiple operating systems.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.