ÔõÑù±àдLinux shell script(Ò»)
½üÀ´ÕýÔÚѧϰLinux shell script£¬Ö÷ÒªÊÇѧϰLinux Shell Scripting Tutorial (LSST) v1.05r3µÄ¼¸¸öÕ½ڣ¬µ«ÒòΪÊÇÓ¢ÎĵÄËùÒÔÕâÀï°ÑËü·ÒëÏ£¬Ò²ÊÇ×Ô¼º¼ÓÉîÓ¡Ï󡣺ÃÁËÖ±½Ó½øÈëÖ÷Ìâ¡£
1.How to write shell script £¿
a.Ê×ÏÈÓÃÈκεıàÒëÆ÷£¨vi,vim,kwrite,....£©±àдһ¸öshell script£»
b.È»ºó°´ÕÕÏÂÃæµÄ·½·¨¸øÄã±àÒëµÄshell scriptÌí¼Ó¿ÉÖ´ÐÐÊôÐÔ£»
chmod Ìí¼Ó(ɾ³ý)ÊôÐÔ ÎļþÃû³Æ
ÀýÈ磺
chmod +x your_script_name »òÕß
chmod 755 your_script_name
Àý×ÓÖеڶþÖз½·¨ÖÐ755±íʾ¶ÔÈý¸ö²»Í¬Àà±ðµÄʹÓÃÕßÉèÖÃÊôÐÔ£¬ÕâÀïÊ×ÏÈ´ó¼ÒÒªÖªµÀLinuxÖеijýÁË¿ÉÒÔÓÃr,w,x±íʾ¿É¶Á£¬¿Éд£¬¿ÉÖ´ÐеÄÊôÐÔÍ⣬»¹¿ÉÒÔÓÃÒ»¸öÊý×Ö´ú±íÒ»ÖÖÊôÐÔ£¬·Ö±ðÊÇr-4,w-2,x-1£¬Ò²¾ÍÊÇ4¾Í±íʾ¿É¶Á£¬2±íʾ¿Éд£¬1±íʾ¿ÉÖ´ÐУ»ÄÇôÈçºÎÉèÖÃÕâЩÊôÐÔÄØ£¿Èç¹ûÎÒÃÇÓó£¹æµÄ·½·¨ÊÇͨ¹ý“+¡¢-”·ûºÅÀ´ÉèÖõģ¬Ò²¾ÍÊÇ"+r"±íʾ¸øij¸öÎļþ¼ÓÉϿɶÁÊôÐÔ£¬"-r"±íʾ¸øij¸öÎļþÈ¥³ý¿É¶ÁÊôÐÔ£»
ÔÚÓÃÊý×Ö±íʾÖÐÊÇÕâÑùÉ趨ÊôÐԵģ¬ÓÃÊý×ÖÉ趨ÊôÐÔ¸ü¼ÓµÄ·½±ã¿ì½Ý£¬Ò»´Î¿ÉÒÔÉ趨Èý¸öÀà±ðʹÓÃÕßµÄÊôÐÔ“ÎļþÓµÓÐÕß”¡¢“ÎļþÓµÓÐÕßËùÔÚµÄ×é³ÉÔ±”¡¢“ÆäËüʹÓÃÕß”£¬ÉÏÃæµÄÀý×ÓÖУ¬7ÊǸøÎļþÓµÓÐÕßÉ趨µÄÊôÐÔ£¬ÄÇ"7"ÊÇʲôÒâ˼ÄØ£¿Æäʵ¾ÍÊǸ÷¸öÊôÐÔÊý×ÖÏà¼ÓµÄ½á¹û£¬Ò²¾ÍÊÇÈç¹ûÄãÒªÉ趨´ËÀàʹÓÃÕßÓÿɶÁ4,¿Éд2,¿ÉÖ´ÐÐ1,ÊôÐÔ£¬ÄÇô¾ÍÊÇ4+2+1 = 7£»´ÏÃ÷µÄÄã¿ÉÄÜÒѾ֪µÀÁËÎļþÓµÓÐÕßËùÔÚµØ×é³ÉÔ±µÄÊôÐÔÊÇ ¿É¶Á ¿ÉÖ´ÐÐ ¼´£º4+1 = 5 £¬ÆäËüʹÓÃÕßµÄÊôÐÔÒ²ÊÇ ¿É¶Á ¿ÉÖ´ÐÐ ¼´£º4+1 = 5. ºÃÁËÊôÐÔÉ趨¾Í²»³¶ÁË£¬¹Ø¼üÊÇÒª¼ÇסchmodÃüÁî¡£
c.±àÒëºÃÁ˽ű¾ÒÔºó¾ÍÊÇÖ´ÐÐÁË
ÕâÀïÌṩÁ½ÖÖ·½·¨Ö´ÐÐÄãµÄ½Å±¾£º
bash your_script_name #ÕâÀïµÄ“#”ºÅÖÐLinux shell scriptÖÐÊDZíʾÆäºóµÄÄÚÈÝΪעÊÍ£»bash ÊÇÎÒÃÇϵͳÖеÄshellÀàÐÍÕâÀï¾Í²»³¶Ô¶ÁË
./your_script_name #½¨Òé´ó¼Ò¾ÍÖ±½ÓÓÓ./”½ÓÄãµÄ½Å±¾Ãû³ÆÖ´ÐУ¬ÎªÊ²Ã´²»ÄÜÏñWindowsÒ»ÑùÖ±½ÓÊäÎļþÃûÖ´ÐÐÄØ£¿Õâ¸öÎÊÌâÇë×Ô¼ºÕÒ´ð°¸
ºÃÁË£¬ÎÒÃÇÏÖÔÚ°ÑÉÏÃæµÄÁ¬¹á×öÒ»±é£»
Ê×ÏȽ¨Á¢Ò»¸ö½Å±¾£¬ÎÒÔÚÕâÀïʹÓÃvi±àÒëÆ÷¡£
$ vi first
ÄÚÈÝÈçÏ£º
#
# My first shell script
#
clear
echo "Knowledge is Power"
±£´æÍ˳ö£»
È»ºóÌí¼Ó¿ÉÖ´ÐÐÊôÐÔ£»
$ chmod 755 first
×îºóÖ´ÐÐ
$ ./fi
Ïà¹ØÎĵµ£º
1. ѧ»áд¼òµ¥µÄmakefile
2. ±àһЩӦÓÃ
³ÌÐò
£¬¿ÉÒÔÓÃmakefileÅÜÆðÀ´
3. ѧ»áдÇý¶¯
µÄmakefile
4. дһ¼òµ¥charÇý¶¯£¬makefile±àÒëͨ¹ý£¬¿ÉÒÔinsmod£¬ lsmod£¬ rmmod. ÔÚÇý¶¯µÄinitº¯ÊýÀï´òÓ¡hello world£¬insmodºóÓ¦¸ÃÄܹ»Í¨¹ýdmesg¿´µ½Êä³ö
¡£
5. дһÍêÕûÇý¶¯£¬ ¼ÓÉÏread£¬ write£¬ ioctl£¬ pollingµÈ¸ ......
Linux·þÎñcannot change directory´íÎó½â¾ö·½·¨
ÔÚ°²×°Íêvsftp·þÎñºóµÇ½ʱ¿ÉÄÜÓöµ½cannot change directoryºóÃæÊǵǽÕßµÄĿ¼µÄ´íÎó¡£ÕâÊÇÒòΪSEÉèÖõĹرÕÁËftpµÄÔÒò¡£
ʹÓÃÃüÁî
getsebool ftpd_disable_trans
¿ÉÒԲ鿴µ±Ç°µÄ״̬Èç¹û²»ÊÇon
ÄÇôÊÇÊäÈëÃüÁî
setsebool ftpd_disable_trans 1
µ±È»Ò²¿ÉÒÔ¼ÓÈë-P² ......
Ç°ÑÔ£º
µ±ÎÒÃÇʹÓÃǶÈëʽlinux ½øÐпª·¢Ê±£¬kernel ÅÜÆðÀ´Ö®ºó£¬ÎÒÃÇÏ£ÍûÄÜͨ¹ý´®¿Ú£¨±ê×¼ÊäÈë¡¢Êä³ö£©£¬ÔÚÓ¦ÓóÌÐòÕýÔÚÔËÐеĹý³ÌÖУ¬½øÐÐһЩµ÷ÊÔ¹¤×÷£¬ÀýÈ磬¶ÔCPUһЩ¼Ä´æ½øÐе÷Õû£¬ÒÔ¹Û²âµ÷ÕûÒÔºóµÄ½á¹û£¬²¢ÇÒ£¬µ±ÎÒÃÇÎÞ·¨°ÑÎÒÃǵÄÓ¦ÓóÌÐò·ÅÔÚºǫ́ÔËÐУ¬ÄÇôÎÒÃǾÍÐèÒªÊ ......
À´Ô´linux-2.6.20.21/Documentation/kbuild/makefiles.txt
* obj-y
+= foo.o ±íʾ±àbuild-in£¬obj-m += foo.o±íʾ±à³Émodule.
* kbuild
»á±àÒëËùÓеÄ$(obj-y)Îļþ£¬È»ºóµ÷ÓÃ$(LD) -r°ÑÕâЩÎļþºÏ²¢µ½Ò»¸öbuilt-in.oÎļþÖС£Õâ¸öbuilt-in.oÉÔºó»á±»¸¸¼¶Makefile linkµ½vmlinux
* ÓÃlib-y
:= checksum.o ......
linuxÏÂfile descriptoerÏÞÖÆ
ĬÈÏ·ÖÀà 2009-11-21 14:47 ÔĶÁ0 ÆÀÂÛ0
×ֺţº ´ó´ó ÖÐÖРСС
Tuning file descriptor limits on Linux
Linux limits the number of file descriptors that any one process may open; the default limits are 1024 p ......