Linux Shell ¡¶abs_guide¡· ѧϰ±Ê¼Ç(1)
µÚÒ»²¿·Ö
1.ΪʲôʹÓÃshell
Ä¿Ç°Á÷ÐеÄLinux shell ±»³Æ֮ΪBASH¡£¶ÔÓÚÈκÎÏëÊʵ±¾«Í¨Ò»Ð©¹ÜÀí֪ʶµÄÈËÀ´Ëµ£¬ÕÆÎÕshell½Å±¾¶¼ÊÇ×î»ù±¾µÄ£»shell½Å±¾×ñѵäÐ͵ÄUNIXÕÜѧ£¬¼È°Ñ´óµÄ¸´ÔӵŤ³Ì·Ö³ÉС¹æÄ£µÄ×ÓÈÎÎñ£¬²¢ÇÒ°ÑÕâЩ²¿¼þºÍ¹¤¾ß×éºÏÆðÀ´¡£
ʲôʱºò²»Ê¹ÓÃshell£º
×ÊÔ´Ãܼ¯ÐÍÈÎÎñ£¬ÓÈÆäÊÇÐèÒª¿¼ÂÇЧÂÊʱ¡££¨±ÈÈçÅÅÐò£¬hashµÈ£©£»
ÐèÒª´¦Àí´óÈÎÎñµÄÊýѧ²Ù×÷£¬ÓÈÆäÊǸ¡µãÔËËãµÈ£»
Óпçƽ̨ÐèÇóʱ£»
¸´ÔÓµÄÔËÓã¬ÔÚ±ØÐëʹÓýṹ»¯±à³Ìʱ£»
¶ÔÓ°Ïìϵͳȫ¾ÖÐԵĹؼüÈÎÎñÓ¦Óã»
¶ÔÓÚ°²È«ÓкܸßÒªÇóµÄÈÎÎñ£»
ÏîÄ¿ÓÉÁ¬´®µÄÒÀÀµµÄ¸÷¸ö²¿·Ö×é³É£»
ÐèÒª´ó¹æÄ£µÄÎļþ²Ù×÷£»
ÐèÒª¶àάÊý×éÖ§³Ö£»
ÐèÒªÊý¾Ý½á¹¹Ö§³Ö£¬±ÈÈçÁ´±í»òÊ÷µÈÊý¾Ý½á¹¹£»
ÐèÒª²úÉú»ò²Ù×÷GUI£»
ÐèÒªÖ±½Ó²Ù×÷ϵͳӲ¼þ£»
ÐèÒªI/O»òSocket½Ó¿Ú£»
ÐèҪʹÓÿâ»òÀÏ´úÂë½Ó¿Ú£»
˽È˵ģ¬±ÏÔ´µÄÓ¦ÓÃ(shell¾Í·ÅÔÚÎı¾ÎļþÖУ¬È«ÊÀ½ç¶¼¿´µÃµ½)¡£
Èç¹ûÄã·ûºÏÉϱߵÄÈκÎÒ»Ìõ£¬ÄÇôÇ뿼ÂǸüÇ¿´óµÄÓïÑÔ°É¡£
2.´ø×ÅÒ»¸öSha-Bang(#!)³ö·¢
ÔÚÒ»¸ö×î¼òµ¥µÄshellÖУ¬Ò»¸öshell scriptÆäʵ¾ÍÊÇһϵÁÐϵͳÃüÁîÁе½Ò»¸öÎļþÖУ¬×î»ù±¾µÄÓô¦¾ÍÊÇÔÚÄãÊäÈëÕâЩÌض¨ÃüÁîʱÄܹ»ÉÙÇÃһЩ×Ö¡£
Example 2-1£ºÇå³ý/var/logϵÄlogÎļþ
#######Start Strip#######
1 # Cleanup
2 # µ±È»ÒªÊ¹ÓÃrootÀ´ÔËÐÐÕâ¸ö½Å±¾
3
4 cd /var/log
5 cat /dev/null > message
6 cat /dev/null > wtmp
7 echo "Logs cleaned up"
#######End Script#######
Õâ¸ù±¾¾ÍûʲôϡÆæµÄ£¬Ö»²»¹ýÊÇÃüÁîµÄ¶Ñ»ý£»°ÑËùÓÐÃüÁî·Åµ½Ò»¸öÎļþÖУ¬ºÃ´¦ÊDz»ÓÃÿ´Î¶¼ÇÃËüÃÇ¡£ÏÂÃæÎÒÃÇÀ´¿´Ò»¸öÕæÕýÒâÒåÉϵĽű¾£¬¶øÇÒÎÒÃÇ¿ÉÒÔ×ߵøüÔ¶...
Example 2-2£ºcleanup£¬Ò»¸öÔöÇ¿µÄºÍ¹ãÒåµÄɾ³ýlogfileµÄ½Å±¾
#######Start Strip#######
1 #!bin/bash
2 # Ò»¸öbash½Å±¾µÄÕýÈ·µÄ¿ªÍ·
3
4 # Clean Version 2
5
6 LOG_DIR = /var/log
7 ROOT_UID = 0 #$UIDΪ0µÄʱºò£¬Óû§²Å¾ßÓиùÓû§µÄȨÏÞ
8 LINES = 50 #ĬÈϵı£´æÐÐÊý
9 E_XCD = 66 #²»ÄÜÐÞ¸ÄĿ¼£¿
10 E_NOTROOT = 67 #²»ÊǸùÓû§£¬Í˳ö
11
12 if [$UID -ne $ROOT_UID]
13 then
14 echo "Must be root user to run this script"
15 exit E_NOTROOT
16 fi
17
18 if [ -n "$1"] #²âÊÔÊÇ·ñÓÐÃüÁîÐвÎÊý£¨·Ç¿Õ£
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
Ò»°ãÔÚlinuxÉϲ¿ÊðÏîĿʱ£¬Ö±½Ó°ÑÔÚwindowÉϱàÒë³öÀ´µÄjarÎļþ²¿ÊðÉÏÈ¥£¬ÔÙÔËÐоͿÉÒÔÁË£¬µ«ÊǽñÌìÅöµ½µÄÎÊÌâ £º
Exception in thread "main" java.lang.NoClassDefFoundError: DataServer
at gnu.java.lang.MainThread.run(libgcj.so.7rh)
Caused by: java.lang.ClassNotFoundException: DataServer ......
ÏñLinuxÄÚºËÕâÑùÅÓ´ó¶ø¸´ÔӵijÌÐò¿´ÆðÀ´È·ÊµÈÃÈËÍû¶øÉú磬ËüÏóÒ»¸öºÜ´óµÄÇò£¬Ã»ÓÐÆðµãºÍÖյ㡣ÔÚ¶ÁÔ´´úÂëµÄ¹ý³ÌÖУ¬Äã»áÓöµ½ÕâÑùµÄÇé¿ö£¬µ±¶Áµ½Äں˵Äijһ²¿·ÖʱÓÖ»áÉæ¼°µ½ÆäËü¸ü¶àµÄÎļþ£¬µ±·µ»Øµ½ÔÀ´µÄµØ·½Ïë¼ÌÐøÍù϶Áʱ£¬ÓÖÍüÁËÔÀ´¶ÁµÄÄÚÈÝ¡£ÔÚinternetÉÏ£¬ºÜ¶àÈËΪ´Ë¸¶³öÁ˺ܴóµÄŬÁ¦£¬ÖÆ×÷³öÁËÔ´´úÂëµ¼º½Æ÷£ ......
¹ØÓÚlinuxµÄ¶Áд²Ù×÷
½¨Á¢ÁËÁ¬½Ó,¾Í¿ÉÒÔ½øÐÐͨѶÁË,ÍùÎļþÃèÊö·ûÀï¶Áд,ºÍ¶ÁдÎļþÊÇÒ»ÑùµÄ.
дº¯Êý:
ssize_t write(int fd,(void *)buf,size_t nbytes)
½«bufÖеÄnbytesдÈëµ½fdÖÐ,³É¹¦Ê±·µ»ØËùдµÄ×Ö½ÚÊý,ʧ°Üʱ·µ»Ø-1,²¢Ð´Èëerrno±äÁ¿.
µ±ÎÒÃÇÏóÌ×½Ó×ÖдÊý¾Ýʱ,¿ÉÄÜ»áÓÐÁ½ÖÖÇé¿ö:
a.writeµÄ·µ»ØÖµ´óÓÚ0,±íʾ ......
FTP>ascii: É趨ÒÔASCII·½Ê½´«ËÍÎļþ(ȱʡֵ)
FTP>bell: ÿÍê³ÉÒ»´ÎÎļþ´«ËÍ,±¨¾¯Ìáʾ.
FTP>binary: É趨ÒÔ¶þ½øÖÆ·½Ê½´«ËÍÎļþ.
FTP>bye: ÖÕÖ¹Ö÷»úFTP½ø³Ì,²¢Í˳öFTP¹ÜÀí·½Ê½.
FTP>case: µ±ÎªONʱ,ÓÃMGETÃüÁ±´µÄÎļþÃûµ½±¾µØ»úÆ÷ÖÐ,È«²¿×ª»»ÎªÐ¡Ð´×Öĸ.
FTP>cd: ͬUNIXµÄCDÃüÁî.
FTP>c ......