20 more handy tips for Linux applications

Source: Internet
Author: User
Article Title: 20 tips to make Linux applications more handy. 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. calculate the number of files and directories
The following statement can help you calculate the number of files and directories.
# Ls-l * | grep "^-" | wc-l ---- to count files
# Ls-l * | grep "^ d" | wc-l ----- to count dir
You can also convert the preceding statement into a script or an alias statement.
2. display file type
Use the command file to let you know whether a file is an executable file in ELF format, a shell script file, or another format, for example: # file startx
3. use the dd command to convert the data format
You probably know that the dd command is used to copy data. It is especially used to create a boot disk. However, dd can also be used for data conversion. On an "endian" system, when exporting the content of the Ingres database, the code may undergo a strange conversion: "The cat in the hat" is changed to "hT eac tnit ehh ta". The method to recover data is to use the dd command:
Dd if = randys_bad_data of = marcs_good_data conv = swab
The last section "conv = swab" tells dd to adopt the "swap bytes" conversion method.
Similarly, if you want to convert data in the EBCDIC format to the ASCII format, you can use the following command:
Dd if = ebcdic_file of = ascii_file conv = ascii
The man help of dd shows that there are no less than 10 conversions. let's take a closer look at it. next time you encounter the same problem, you can use dd to help.
4. do not use the ping command.
The ping command is an application that checks the connection between computers. data transmission between computers is not encrypted, therefore, when we use the ping command to detect a server, an illegal element may exist on the Internet, and the information transmitted on the network line may be stolen through a special hacker program, attackers can exploit the stolen information to attack the specified server or system. Therefore, we need to disable Linux commands in Linux. In linux, if you want to make ping unresponsive, that is, to ignore the icmp packet, you can enter the following command in the Linux command line: echo 1>/proc/sys/net/ipv4/icmp_echo_igore_all;
If you want to resume using the ping command, enter the command echo 0>/proc/sys/net/ipv4/icmp_echo_igore_all.
5. display the long file name in the Win9X partition
If you find that the long file life in the Win9X partition cannot be displayed, you can mount it in vfat mode again. You can modify the/etc/fstab file for the mount partition at startup and change the msdos text to vfat. If you cannot use vfat mount, recompile the core and add support for vfat.
6. Norton Commander in Linux
After you type the command mc at the prompt, you will see a very strong interface with Norton commander, and the functions on the page are also very powerful, such as directly performing the files in the .tar.gz package (a bit like ZipMagic ).
7. directly go to X after startup
Edit the/etc/inittab file and change id: 3: initdefautl to id: 4: initdefautl. However, there may be some problems with the search path. when you shut down the system, you must directly go to/*** in to execute shutdown.
8. cleverly use the "Tab" key
You know that when you enter commands on the Linux character interface, you sometimes need to enter many characters. it is troublesome to enter the characters one by one. If 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, if you want to unpackage the directory/ccc's file "export ddddddddd-1.2.3.tar.gz", when you type "tar xvfz/ccc/d" in the command line, if the file is the only file in the directory with the "d" header, you can directly press the "Tab" key, then the command will be automatically filled with: tar xvfz/ccc/ddddddd-1.2.3.tar.gz, this improves the input efficiency.
9. force exit X
Sometimes in X, the mouse and keyboard do not work due to program errors. in this case, don't worry, because in Linux, there is almost no vicious crash like in Win95, you only need to press Ctrl + Alt + BackSpace to return to the character interface.
10. after Win9x is reinstalled, lilo cannot start Linux.
You only need to start Linux with a floppy disk and run lilo once. For RedHat, run mkbootdisk to create a boot disk. for example:
Mkbootdisk -- devices/dev/fd0 2.0.34-1. 2.0.34-1 is a directory under/lib/modules.
11. remove the lilo information in the pilot zone.
After lilo is installed, if the number or partition of the hard disk changes, the hard disk cannot be started. in this case, you only need to use a floppy disk to start dos and then run fdisk/mbr. (This method can also be used to clear viruses in any boot zone)
12. how to view files
If you only want to view the first five lines of the file, can you? * ** The ead command, such as head-5/etc/passwd. if you want to view the last 10 lines of the file, you can use the tail command, for example: tail-10/etc/passwd do you know how to view the middle part of the file? You can use the sed command, for example, sed-n'5, 10p'/etc/passwd, to view only rows 5th to 10th of the file.
13. eliminate crashes in Xwindows
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 and hold the "Ctrl + Alt + F2" compound key on the keyboard to switch the system to another platform, log on to the system, and then run the "# ps-ax/grep startx" command, this will list the process IDs 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, return to the original platform through the Alt + F1 compound key.
14. use the current path as the prompt
For bash, add a line in. bashrc: PS1 = "\ $ PWD \ $"
For tcsh, add a line in. tcshrc: set prompt = "%/>"
15. quickly shut down the Linux system
The latest version of Linux/UNIX systems draws on the mainframe technology and uses a log file system that prevents power loss. it can automatically track and save user data and automatically refresh the file system synchronously, you can turn off the power at will to quickly shut down the system.
16. fixed the Linux super user password.
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.
17. process a whole directory at a time
Many common Linux/UNIX commands, such as rm and cp, have a parameter "-r", which indicates recursion, you can add the "-r" parameter to the command to perform operations on the target directory and all its subdirectories, for example:
Rm-rf/test (f is force). This command completely deletes the sub-directory test in the root directory, which is similar to the deltree in dos, be especially careful when using this command. Another example is cp-r/test/test1, which is similar to xcopy/s in dos.
18. list all files in the current directory except for some types of files
Use Ksh and ls! (*. Z) displays all files except *. Z. This command is useful when there are many types of files in a directory.
19. create a LILO boot disk
Change boot =/dev/hdxx in/etc/lilo. conf to/dev/fd0, and then run lilo-v to write LILO to the disk. then the LILO boot disk is ready. Note: after the boot disk is complete, change boot =/dev/fd0 back to the original settings, and run lilo-v again to write back the master boot record or Super Block.
20. use the nohup command
If you want the process to be executed after you exit the system, you can use the NOHUP command, for example, % nohup tar-cf/dev/tape/home. after you exit, log on again, run the 'Ps' command to check that the process is still being executed.
  
  

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.