12 tips for using Linux

Source: Internet
Author: User
Article Title: 12 tips for using Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   1. Process special file names
  
Suppose there is a file name named "-aaa" in Linux. If we want to operate on it, for example, to delete it now, if we enter the rm-aaa command in the command line according to the general deletion method, the interface will prompt that we are 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 enter 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 use double quotation marks to enclose the entire file name.
  
   2. Fix the Super User Password in Linux
  
If a Super User forgets the password, he or she cannot access the system or manage and use the system. This is unlikely to happen, but it is quite easy for some Linux standalone users, especially beginners. The general solution is to format the hard disk and reinstall the system. Prepare two floppy disks, bootdisk and rootdisk, start from the floppy disk, start to the root disk, and a shell prompt appears. Mount the Linux root directory to the/mnt directory. For example, if your Linux is in the first partition of the hard disk, enter mount/dev/hda1/mnt in the command line and enter the mnt directory, rename the etc/passwd file and enter mv/mnt/etc/passwd. then run 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, in this way, the hard disk is restarted, and the super password will not be asked during logon. The mv/etc/passwd will be used. the bak passwd command changes the passwd file back, and then runs the passwd command to reset the password.
  
   3. install Linux directly
  
Generally, when installing an operating system software, you need to start the boot disk of the system to install it. However, when installing the Linux operating system, we can use a DOS software named loadlin.exe on the system disc to directly transfer the Linux core to the memory, the Linux core takes over the computer instead of the current operating system and enters the Linux installation interface. When installing Linux, you only need to enter loadlin E: imagesvmlinuz root =/dev/ram initrd = E: imagesinitrd. the img command can directly install Linux, where E is the drive letter, and E: imagesvmlinuz is the Linux core name.
  
   4. quickly start the Linux System
  
With the increasing configuration of personal computers, installing Linux on your computer is no longer a new problem. Suppose we have two windows and Linux operating systems installed on our computer, how should we start Linux? Do you need to restart the computer every time and boot through LiLo? In fact, if we use dos, there is a simple and fast way to start Linux, that is, load Linux. Loadlin.exe is an executable program in dos. It can quickly start Linux in a pure dos environment without restarting the computer, we can find this program in the/kernels directory of the CD. If you do not know where the program is stored on the installation disk, you can use the "find-name loadlin *" command to find it. Copy it to the dos partition and copy the Linux Kernel File you are using. You can copy files directly from the CD in windows, or use the mcopy command in Linux to copy the files to the dos partition, and then write a Linux. bat batch file. The file content is as follows: c: loadlin c: vmlinuz root =/dev/hda1 ro
  
In this example, we assume that both the loadlin.exe and vmlinuz kernel files are in the c root directory, while the root is the Linux root device and Linux is in the first partition of the hard disk. Therefore, the device name is/dev/hda1 and ro indicates readonly. In the future, you can run Linux. bat to start Linux in dos. In this way, Linux is started quickly and efficiently, greatly reducing the waiting time during system self-check.
  
   5. Eliminate crashes in Xwindows
  
If we run Linux in Xwindows, the system may suddenly lose response due to hardware problems or improper operations, this is also a common phenomenon of crashes. In fact, the system does not crash at this time. We can use two common methods to eliminate this phenomenon: first, use the composite key Ctrl + Alt + Backspace on the keyboard to close the currently running task; second, press Ctrl + Alt + F2 on the keyboard to switch the system to another console, log on to the system, and then run the # ps-ax | grep startx command, this will list the process ID (PID) of your Xserver, and then enter the following command in the command line to eliminate the crash phenomenon in Xwindows: # kill-9 PID_Number, finally, the original platform is returned through the Alt + F1 compound key.
  
   6. Quickly shut down the Linux System
  
In earlier versions of Linux/UNIX, the shutdown command must be run before the power can be switched off. However, the latest version of Linux/UNIX has made great improvements in this regard, there is no need to shut down as before. Because the new version of the system draws on the mainframe technology and uses a log-based file system that prevents power loss, it can automatically track and save user data and automatically synchronize and refresh the file system. Users can turn off the power at will, to Quickly shut down the system.
  
   7. cleverly use the rm command
  
We know that in the Linux character interface, you can use the rm command to delete a file. You can use the rmdir command to delete a directory. However, the rmdir command can only delete blank directories. If there are files under a directory, you can only delete the files in the directory with the rm command, therefore, rmdir and rm commands are usually used together to completely delete a complete directory. However, this method can be used to deal with several levels of sub-directories. If a directory contains several sub-directories, and these sub-directories contain several levels of sub-directories, using this method will not exhaust you. Now we can use the rm command with the-r parameter to delete a non-empty directory. For example, we can enter commands like rm-r bbb in the command line, the system deletes all files and subdirectories in the bbb directory.
  
   8. Make full use of the virtual console
  
After logging on to Linux, if we press Alt + F2 on the keyboard, we can see a Shell prompt, which is actually the second virtual operating station. Generally, the newly installed Linux system has four virtual consoles. We can use the composite keys Alt + F1, Alt + F2, Alt + F3, and Alt + F4 to access them. When a program fails to lock the input or the Linux system suddenly loses response, you can log on to other virtual consoles and kill the faulty process task.
  
   9. Add virtual cache
  
If SWAP (SWAP space) on the computer is insufficient, as long as there is space available on the 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 file, just write it according to the original swap. Use "free" to check the swap size. Linux supports up to 16 swap partitions, with each swap partition up to 128 MB. When there is no idle partition, you can use a large file to create it. The following are a series of commands:
  
# Dd if =/dev/zero of = swapfile bs = 1024 count = 8192 # mkswap swapfile 8192 # sync # swapon swapfile
  
   10. Clever Use of the Tab key
  
You know that when you enter commands on the Linux character interface, you sometimes need to enter many characters. It is cumbersome to input characters one by one. Assuming that the entered characters are sufficient to determine the next unique file in the directory, we only need to press the Tab key on the disk to automatically complete the remaining parts of the file name, for example, to unpackage the file ddddddd-1.2.3.tar.gz under the directory/ccc, when we type tar xvfz/ccc/d in the command line, if the file is the only file starting with d in the directory, you can directly press the Tab key on the keyboard, the command will be automatically filled with: tar xvfz/ccc/ddddddd-1.2.3.tar.gz, this improves the input efficiency.
  
   11. Copying and pasting are used to increase the operation speed.
  
After Linux is installed, a program named gpm is automatically run every time the character interface is started. After the program runs, you can copy and paste it with your mouse. The specific method is to press and hold the left mouse button to highlight the area to be copied. The highlighted area has been copied, right-click the copied content and paste it at the cursor position. If we run the Linux System in Xwindow, the copy and paste operations are the same as those in the normal Win9x system.
  
   12. Accelerate Linux Data Access
  
If we want to quickly improve the hard drive reading data in Linux, we can make some settings in Linux so that Linux can 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 enable the 32bit transmission mode, run/sbin/hdparm-dl/dev/hda to enable the DMA transmission mode, then enter the command/sbin/hdparm-kl/dev/hda to keep the above settings after Reset, we can increase the speed of reading disks in Linux to more than doubled.
Related Article

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.