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

Sharing skills commonly used in linux system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces "sharing skills commonly used in linux system". In daily operation, I believe many people have doubts about sharing skills commonly used in linux system. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "sharing skills commonly used in linux system". Next, please follow the editor to study!

1. Handle special file names

Suppose there is a file in the Linux system called "- aaa". If we want to operate on it, for example, if we want to delete it now, if we type the rm-aaa command on the command line according to the general deletion method, the interface will prompt us that it is an invalid option (invalid option). Because the first character of the file name is -, Linux regards the file name as an option. We can use the "- -" symbol to solve this problem, for example, we can type the rm-aaa command to delete the-aaa file. If it is another special character, you can add a "" symbol before the special character, or enclose the entire file name in double quotation marks.

2. Repair the password of the superuser under Linux

If the superuser forgets his password, he will not be able to enter the system or manage and use the system. This is unlikely to happen, but it is more likely to happen to some Linux stand-alone users, especially among beginners. The general solution is to format the hard drive to reinstall the system, but this is a bit of a mountain out of a molehill. Prepare the bootdisk and rootdisk floppy disks, boot from the floppy drive, boot to the root disk and appear at the shell prompt. Partition the Linux root directory to the / mnt directory. For example, if your Linux is in the first partition of your hard disk, type mount / dev/hda1 / mnt on the command line, then enter the mnt directory, rename the etc/passwd file in it, and type 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 on the hard disk, so that the super password will not be asked when logging in again from the hard disk; 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.

3. Install Linux directly.

Usually when we install an operating system software, we need the boot disk of the system to boot before we can install it. However, when we install the Linux operating system, we can use a DOS software named loadlin.exe in the CD of the system to call the Linux core directly into memory, and the Linux core will take over the computer instead of the current operating system, and enter the Linux installation interface. When installing Linux, we can install Linux directly by typing the command loadlin E:imagesvmlinuz root=/dev/ram initrd=E:imagesinitrd.img in the run dialog box, where E is the letter of the CD drive and E:imagesvmlinuz is the Linux core name.

4. Start the Linux system quickly

With the increasing configuration of personal computers, it is nothing new to install Linux systems on your own computers. Suppose we have both windows and Linux operating systems on our computer, how should we start Linux? Do you need to restart your computer every time and boot via LiLo? In fact, if we have a simple and quick way to start Linux under dos, that is load Linux. Loadlin.exe is an executable program under dos. It can quickly start Linux in a pure dos environment without restarting the computer. This program can usually be found in the / kernels directory of the CD. If you don't know where the program is placed on the installation disk, you can use the "find-name loadlin*" command to find it. Find it and copy it to the dos partition. You also need to copy a copy of the Linux kernel file you are using. You can copy the file directly from the CD through windows, or you can use the mcopy command to copy the file to the dos partition in the Linux environment, and then write a batch file for Linux.bat with the following contents: c:loadlin c:vmlinuz root=/dev/hda1 ro

We assume that the two kernel files, loadlin.exe and vmlinuz, are in the root directory of disk c, while root is the root device of Linux, and Linux is in the first partition of the hard disk, so the device name is / dev/hda1, which means readonly. In the future, when you want to start Linux under dos, just run Linux.bat. In this way, it is fast and efficient to start Linux, which greatly reduces the waiting time for system self-test.

5. Eliminate the crash phenomenon under Xwindows.

If we run Linux in Xwindows state, due to hardware problems or improper operation, sometimes the system may suddenly lose response, that is, we often see a panic phenomenon, in fact, the system does not crash at this time. We can eliminate this phenomenon in two common ways: first, use the compound key Ctrl+Alt+Backspace on the keyboard to close the currently running task Second, first press and hold the Ctrl+Alt+F2 compound key on the keyboard, let the system switch to another console, then log in to the system, and then execute the # ps-ax | grep startx command, which will list the process ID of your Xserver (PID), and then enter the following command on the command line to eliminate the panic under Xwindows: # kill-9 PID_Number, and finally return to the original platform through the Alt+F1 compound key.

6. Quickly shut down the Linux system

The old version of the Linux/UNIX system had to run the shutdown command before it could be powered off, but the latest version of the Linux/UNIX system has made great improvements in this area and there is no need to shut down as before. Because the new version of the system draws lessons from the mainframe technology and adopts a power-resistant log file system, it can automatically track and save user data and automatically synchronously refresh the file system, and users can turn off the power at will. In order to achieve the purpose of shutting down the system quickly.

7. Ingenious use of rm command

We know that in the Linux character interface, you can use the rm command to delete a file and the rmdir command to delete a directory. However, because the rmdir command can only delete a blank directory, if there are files under a directory, you can only use the rm command to delete the files in the directory first, so you usually need to use the rmdir and rm commands to completely delete a complete directory. But this method to deal with several levels of subdirectories can also make do, if a directory contains several subdirectories, and these subdirectories also contain several levels of subdirectories, and then use this method will not make you tired to death. Now we can use the rm command with the-r argument to delete a non-empty directory. For example, we enter a command such as rm-r bbb on the command line, which means that the system will delete all files and subdirectories contained in the bbb directory.

8. Make good use of the virtual console

When we log in to the Linux system, if we press the Alt+ F2 key on the keyboard, we can see another Shell prompt, which is actually the second virtual console. Usually, there are four virtual consoles in the newly installed Linux system, which can be accessed by compound keys Alt+F1, Alt+F2, Alt+F3, and Alt+F4, respectively. The most frequent place to use the virtual console is that when a program goes wrong and locks the input or when the Linux system suddenly loses its response, it can switch to another virtual console to log in and kill the wrong process task.

9. Add virtual cache

If the SWAP on the computer (swap space) is not enough, as long as we have spare space on our hard disk, we can use the remaining space, we can directly use 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. Use "free" to check the size of the swap. Linux supports up to 16 swap partitions, each with a maximum of 128m. When there is no free partition, it can be created with a large file. Here is a series of commands to be executed:

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

# mkswap swapfile 8192

# sync

# swapon swapfile

10. Ingenious use of Tab key

As we all know, when entering commands in the Linux character interface, you sometimes need to enter a lot of characters. If you often enter characters one by one like this, it will be more cumbersome. Assuming that enough characters are typed to determine a unique file under the directory, we can automatically complete the rest of the file name by pressing the Tab key on the keyboard, for example, when we want to unpack the file ddddddd-1.2.3.tar.gz under the directory / ccc, when we type tar xvfz / ccc/d on the command line If the file is the only file in this directory that starts with d, you can press the Tab key on the keyboard directly, and the command will be automatically completed to: tar xvfz / ccc/ddddddd-1.2.3.tar.gz, thus improving the input efficiency.

11. Use more copy and paste to improve operation speed

After the Linux system is installed, every time you start to the character interface, you will automatically run a program called gpm, which can be copied and pasted with the mouse. The specific method is to press and hold the left mouse button and drag to highlight the place you want to copy, then the highlighted area has been copied, and then the content copied by pressing the right mouse button will be pasted at the location of the cursor. If we run the Linux system under Xwindow, the copy and paste operation is the same as under a normal Win9x system.

12. Speed up Linux access to data

If we want to quickly improve the data read by the hard disk under Linux, we can make some settings under Linux to let Linux work in 32-bit input / 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 transfer 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 to make the hard disk still maintain the above settings after Reset. Through these settings, we can improve the disk reading speed of Linux to more than twice.

13. Use the first aid 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 can be used to start and run a complete Linux system independently. In fact, the second disk in the first aid disk group has a complete Linux system, including the root file system, while the first disk holds a bootable kernel.

It is easy to use the emergency disk group maintenance system. Just use these two disks to start the system and enter the first aid mode, where the root account is used. In order to access the files on the hard disk, you need to install the hard disk file system manually. For example, the ext2fs type Linux file system on the / dev/ hda2 disk can be mounted in the / mnt directory with the following command:

# 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 to 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.

14. What to do when the file system is destroyed

When the file system is corrupted, if you are using an ext2fs type file system, you can run the e2fsck command from the floppy disk to correct the corrupted data in the file system. For other types of file systems, you can use the appropriate fsck command.

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

Note: the common cause of file system corruption is that the super block is corrupted, which is the "header" of the file system. It contains information such as the status, size, and free blocks of the file system. If a super block of a file system is corrupted (such as accidentally writing data directly to the super block partition of the file system), the file system may not be recognized at all, so it cannot be mounted and cannot be handled even with the e2fsck command.

However, ext2fs-type file systems back up the contents of the super block and store it at the driver's block group (block group) boundary. You can tell e2fsck to use the backup of the super block with the following command

# e2fsck-b 8193

Refers to the partition where the file system is located, and the-b 8193 option is used to display backup data using super blocks of 8193 blocks stored in the file system.

15. Recover lost files

If you accidentally delete an important file, there is no way to restore it directly. However, the corresponding files can also be copied from the first aid disk to the hard drive. For example, if the file / bin/login is deleted and the system does not enter the login interface properly, you can boot the system with the first aid disk group, 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 tells cp to maintain access to the file when copying. Of course, this method cannot be used if the deleted basic file is not in the first aid disk group. If you have done a system backup before, you can also use the previous backup to restore it.

4. The treatment method when the function library is destroyed.

If you accidentally break the system function library files, or break the symbolic links in the / lib directory, you will cause commands that depend on these libraries to fail to execute. The easiest solution is to boot the system with the first aid disk pack, install the hard disk file system in the / mnt directory, and then repair the libraries in the / mnt/lib directory.

16. Unable to log in to the system with root account

Due to the negligence of the system administrator, or because the system has been hacked, the system administrator may not be able to log in to the system with the root account.

For the first case, the system administrator may have forgotten the root password, and the problem can be solved with a first-aid disk group.

In the second case, the system administrator is unable to enter the system because the password is likely to be changed by a hacker, that is, the Linux system is completely out of control, so control of the system should be regained as soon as possible. After obtaining root authority, you should also check if the system is damaged in order to prevent hackers from invading again.

The most important thing to do is to reset the root password to gain control of the Linux operating system. First boot the system with the first aid disk group, then install the file system of the hard disk into the / mnt directory, edit the / mnt/etc/passwd file, and empty the line of encrypted password fields corresponding to the root account, as follows:

Root::0:0:root:/root:bin/bash

Note: if the system uses the shadow tool, you need to do the above on the file / etc/shadow so that the root login system does not need a password.

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

17. The Linux system cannot be started

In general, if the system administrator cannot enter the system normally, you need to consider using the emergency disk group to enter the first aid mode to troubleshoot the system. But in the absence of a first-aid disk group, the Linux system can not be started, what should I do?

When using a Linux system on a personal computer, Linux and MS Windows 9x or MS Windows NT usually coexist.

Reinstalling other operating systems often causes the original Linux to fail to boot. This is mainly because these operating systems default to no other operating system in the computer, so they rewrite the master boot record (MBR) of the hard disk and flush out the LILO system boot program of Linux.

If there is a first-aid disk set, it is simple to start the Linux system of the hard disk with the first boot disk, rerun the LILO command, and write the LILO system boot program back to the master boot record of the hard disk. Just turn it on again.

If there is no system boot disk, how to restore the Linux on the hard disk? In this case, if you know the exact partition where Linux is installed on your hard disk, and you have a loadlin program, you can return to Linux. Loadlin program is a program under DOS. Running it can start Linux directly from DOS and quickly enter the Linux environment. This program can be found in the dosutil/ directory of the Red Hat Linux 6.0CD. In addition, you need an image file of the Linux boot kernel. In Red H

This file, vmlinuz, is found in the images/ directory of the at linux 6.0CD.

For example, under the Windows 98 system, enter the single-user mode of DOS and 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 Linux's root file system is located. After the command is executed, the Linux system is booted. After logging in with root and running the LILO command, the LILO is reloaded into MBR, returning to the previous state of co-use of multiple operating systems.

At this point, the study of "sharing skills commonly used in linux systems" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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