Skills accumulated in Linux over the past five years (3)-system (II)

Source: Internet
Author: User

Skills accumulated in Linux over the past five years (3) -- skills accumulated in Linux over the past five years (2) -- skills accumulated in the system (I) http://www.bkjia.com/ OS /201303/193589.html this article mainly introduces some of the Linux system skills. Author of JH Gao <gaopenghigh@gmail.com> from the beginning of Linux has been in touch with the present for five years, and everyone is the same, it is indispensable to toss. Once in a while, I will record the method. Now I will briefly summarize it. The command functions of www.2cto.com can be found through man. I only list what I think is commonly used. 1. in bash, the $ related parameter Shell code $0 indicates the current file name $ *. All parameters are separated by spaces to form a string $ @-. All parameters are separated by spaces to form a string combination. Different from $ *, when being referenced by "", "$ *" is a string, "$ @" contains multiple strings $ #-number of parameters passed to the process $? -The execution result of the previous command. If no error occurs, the value 0 $-PID 2 of this command. bash technique, which combines the content of a variable into the name EXAMPLE of another variable: shell code A_ B _C_D = "something" t1 = "B" t2 = "_ D" eval echo \ $ A _ $ {t1} _ C $ {t2}; 3. thinkPad X220 setting in Ubuntu (12.04, 12.10, set the sensitivity and speed respectively. Shell code echo-n 225>/sys/devices/platform/i8042/serio1/serio2/sensiti1_echo-n 115>/sys/devices/platform/i8042/ serio1/serio2/speed 4. back up the Main Boot Sector (bootsector) if the Startup File is corrupted, you can restore the Main Boot Sector to view the repair: Back up Shell code d D if =/dev/hda of = bootsector. img bs = 512 count = 1 restore Shell code dd if = bootsector. the above two steps of img of =/dev/hda only restored the primary boot sector. It is likely that all the content in/boot must be restored before it can be started normally, you can also back up the files under/boot. 5. bash command line Input tips: use Ctrl + R to search for previously used commands use Ctrl + W to delete the current single-time use Ctrl + U to delete the current row 6. xargs is very powerful. You can use-l {} to specify the parameter location: EXAMPLE Shell code cat hosts | xargs-I {} ssh root @ {} hostname 7. write a safe bash Script: set-e. When an error occurs, the script will exit set-u. When bash finds that there are initialization variables, it will exit. For more information, see: write a robust Bash script 8. tar package the files listed in the specified list: Shell code cat yourlist. lst/etc/fstab/home/admin/bin/somefile. sh/home/mysql/somefile... tar cvzf xxx.tar.gz-T yourlist. lst 9. specify a DNS server to query domain names Record the Shell code dig @ 8.8.8.8 www.google.com 10. the most important parameters of the sort command are-k and-s: Shell code-s, -- stable stabilize sort by disabling last-resort comparison stable. EXAMPLE Shell code $ cat a.txt a a B B $ sort-f a.txt a A B B $ sort-f-s a.txt a a B B in the EXAMPLE,-f indicates not case sensitive, -s indicates that the sequence depends on the sequence Shell code of the original file-k, -- key = POS1 [, POS2] start a key at POS1 (origin 1 ), end it at POS2 (default end of line ). therefore, we should write the command in the second column: Shell code sort-k1, 1

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.