GNU/Linuxƽ̨µÄC³ÌÐò¿ª·¢¼°³ÌÐòÔËÐл·¾³
±¾ÎĽéÉÜÔÚGNU/Linux»·¾³ÏÂÒ»¸öC³ÌÐòÓÉÔ´´úÂëµ½³ÌÐò£¬µ½¼ÓÔØÔËÐУ¬×îºóÖÕÖ¹µÄ¹ý³Ì¡£Í¬Ê±ÒԴ˹ý³ÌΪÔØÌ壬½éÉÜGNU/Linuxƽ̨ÏÂÈí¼þ¿ª·¢¹¤¾ßµÄʹÓá£
±¾ÎÄÒÔÎÒÃÇ×î³£¼ûµÄhello, world!ΪÀý£º
#include <stdio.h>
main ()
{
printf(“hello, world!\n”);
}
C³ÌÐòÉú³É
ÏÂͼÊÇÒ»¸öÓÉCÔ´´úÂëת»¯Îª¿ÉÖ´ÐÐÎļþµÄ¹ý³Ì£º
´úÂë±à¼: ±È½ÏÁ÷Ðеıà¼Æ÷ÊÇGNU EmacsºÍvim¡£Emacs¾ßÓзdz£Ç¿´óµÄ¹¦ÄÜ£¬²¢ÇÒ¿ÉÀ©Õ¹¡£
±àÒ룺°üÀ¨±àÒëÔ¤´¦Àí£¬±àÒ룬»ã±à£¬Á¬½Ó¹ý³Ì¡£ËüÃǶ¼¿ÉÒÔͨ¹ýGCCÀ´ÊµÏÖ¡£¹ØÓÚGCC£¬¿ÉÒԲο¼ÎÒ¹ØÓÚGCCµÄ±Ê¼Ç¡£
C±àÒëÆ÷½«Ô´Îļþת»»ÎªÄ¿±êÎļþ£¬Èç¹ûÓжà¸öÄ¿±êÎļþ£¬±àÒëÆ÷»¹½«ËüÃÇÓëËùÐèµÄ¿âÏàÁ¬½Ó£¬Éú³É¿ÉÖ´ÐÐÄ£¿é¡£µ±³ÌÐòÖ´ÐÐʱ£¬²Ù×÷ϵͳ½«¿ÉÖ´ÐÐÄ£¿é¿½±´µ½ÄÚ´æÖеijÌÐòÓ³Ïó¡£
³ÌÐòÓÖÊÇÈçºÎÖ´ÐеÄÄØ£¿Ö´ÐÐÖеijÌÐò³Æ֮Ϊ½ø³Ì¡£³ÌÐòת»¯Îª½ø³ÌµÄ²½ÖèÈçÏÂ:
1£¬ Äں˽«³ÌÐò¶ÁÈëÄڴ棬Ϊ³ÌÐò¾µÏñ·ÖÅäÄÚ´æ¿Õ¼ä¡£
2£¬ ÄÚºËΪ¸Ã½ø³Ì·ÖÅä½ø³Ì±êÖ¾·û£¨PID£©¡£
3£¬ ÄÚºËΪ¸Ã½ø³Ì±£´æPID¼°ÏàÓ¦µÄ½ø³Ì״̬ÐÅÏ¢¡£
¾¹ýÉÏÊö²½Ö裬³ÌÐòת±äΪ½ø³Ì£¬¼´¿ÉÒÔ±»µ÷¶ÈÖ´ÐС£
ÉÏÊöµÄhello, world³ÌÐòʵ¼ÊÊDz»¹æ·¶µÄ£¬POSIX¹æ¶¨mainº¯ÊýµÄÔÐÍΪ£º
int main( int argc, char *argv[])
argcÊÇÃüÁîÐвÎÊýµÄ¸öÊý£¬argvÊÇÒ»¸öÖ¸ÕëÊý×飬ÿ¸öÖ¸ÕëÔªËØÖ¸ÏòÒ»¸öÃüÁîÐвÎÊý¡£
e.g: $ ./a.out arg1 arg2
argc = 4
argv[0] = ./a.out argv[1] = arg1 argv[2] = arg2
C³ÌÐòµÄ¿ªÊ¼¼°ÖÕÖ¹
³ÌÐòµÄÔËÐУº
ΨһÈë¿Ú£ºexecº¯Êý×壨°üÀ¨execl, execv, execle, execve, execlp, execvp£©
³ÌÐò¿ªÊ¼Ö´ÐÐʱ£¬ÔÚµ÷ÓÃmainº¯Êý֮ǰ»áÔËÐÐCÆô¶¯Àý³Ì£¬¸ÃÀý³Ì½«ÃüÁîÐвÎÊýºÍ»·¾³±äÁ¿´ÓÄں˴«µÝµ½mainº¯Êý¡£
³ÌÐòµÄÖÕÖ¹£ºÓÐ8ÖÖ;¾¶£º
Õý³£ÖÕÖ¹£º
1£¬ ´Ómain·µ»Ø¡£
2£¬ µ÷ÓÃexit¡£
3£¬ µ÷ÓÃ_exit»ò_Exit¡£
4£¬ ´Ó×îºóÒ»¸öÏ̵߳ĿªÊ¼Àý³Ì·µ»Ø¡£
Òì³£ÖÕÖ¹£º
5£¬ µ÷ÓÃabort¡£
6£¬ ½ÓÊÕµ½Ò»¸öÖÕÖ¹Ðźš£
7£¬ ¶Ô×îºóÒ»¸öÏ̷߳¢³öµÄÈ¡ÏûÇëÇó×ö³öÏìÓ¦¡£
_exi
Ïà¹ØÎĵµ£º
Îļþϵͳ
ÎļþϵͳµÄ²Ù×÷¹Ûµã
--²Ù×÷ϵͳÓÃÓÚÃ÷È·´ÅÅÌ·ÖÇøÉϵÄÎļþµÄ·½·¨ºÍÊý¾Ý½á¹¹£¬¼´ÎļþÔÚ´ÅÅÌÉϵÄ×éÖ¯·½·¨
--LinuxʹÓÃ"ÐéÄâÎļþϵͳ"²Ù×÷¸÷ÖÖÀàÐ͵ÄÎļþϵͳ
ÎļþϵͳµÄÓû§¹Ûµã
--LiunxϵÄËùÓÐÎļþºÍĿ¼£¬ÕâЩÎļþ¼°Ä¿Â¼¹¹ÒÔÒ»¸öÊ÷×´µÄ½á¹¹£¬¹¹³ÉÁËLinuxÖеÄÎļþϵͳ
--LinuxÎļþ±ê×¼£¨Linux File System St ......
Ŀ ¼
1.1 Ç°ÑÔ£º... 4
1.2 °²×°¼°ÅäÖò½Ö裺... 4
1.2.1 £º°²×°×¼±¸... 4
1.2.2 £º°²×°·½Ê½Ñ¡Ôñ... 4
1.2.3 £º¹âÅ̼ì²â... 5
1.2.4 £º»¶Ó½çÃæ... 5
1.2.5 £ºÑ¡Ôñ°²×°¹ý³ÌµÄÓïÑÔ¡£... 6
1.2.6 £º¼üÅ̺ÍÊó±êÉèÖÃ... 6
1.2.7 £º´ÅÅÌ·ÖÇø·½Ê½Ñ¡Ôñ... 7
1.2.8 £º¸ñʽ»¯È·ÈÏÐÅÏ¢... 8
1.2.9 £º½¨·ÖÇø... 8
1. ......
http://content.hccfl.edu/pollock/AUnix1/FilePermissions.htm
http://en.wikipedia.org/wiki/Sticky_bit
http://www.anqn.com/os/linux/2009-03-01/a09108173.shtml
7.4.3 ÎļþÌØÊâȨÏÞ£ºSUID/SGID/Sticky Bit
Ç°ÃæÒ»Ö±Ìáµ½ÎļþµÄÖØҪȨÏÞ£¬¾ÍÊÇrwxÕâ3¸ö¶Á¡¢Ð´¡¢Ö´ÐеÄȨÏÞ¡£µ«ÊÇ£¬Ôõô /tmpȨÏÞÓÐЩÆæ¹Ö ......
tar [-cxtzjvfpPN] ÎļþÓëĿ¼ ....
²ÎÊý£º
-c £º½¨Á¢Ò»¸öѹËõÎļþµÄ²ÎÊýÖ¸Áî(create µÄÒâ˼)£»
-x £º½â¿ªÒ»¸öѹËõÎļþµÄ²ÎÊýÖ¸Á
-t £º²é¿´ tarfile ÀïÃæµÄÎļþ£¡
Ìرð×¢Ò⣬ÔÚ²ÎÊýµÄÏ´ïÖУ¬ c/x/t ½öÄÜ´æÔÚÒ»¸ö£¡²»¿Éͬʱ´æÔÚ£¡
ÒòΪ²»¿ÉÄÜͬʱѹËõÓë½âѹËõ¡£
-z £ºÊÇ·ñͬʱ¾ßÓÐ gzip µÄÊôÐÔ£¿Ò༴ÊÇ·ñÐ ......