¶ÑÕ»¡¢linux c³ÌÐò´æ´¢¿Õ¼ä²¼¾ÖµÄ×ܽá
Õ»Ö÷ÒªÓÃÀ´´æ·Å¾Ö²¿±äÁ¿, ´«µÝ²ÎÊý, ´æ·Åº¯ÊýµÄ·µ»ØµØÖ·.esp ʼÖÕÖ¸ÏòÕ»¶¥, Õ»ÖеÄÊý¾ÝÔ½¶à, espµÄֵԽС.
¶ÑÓÃÓÚ´æ·Å¶¯Ì¬·ÖÅäµÄ¶ÔÏó, µ±ÄãʹÓà malloc , new µÈ½øÐзÖÅäʱ,ËùµÃµ½µÄ¿Õ¼ä¾ÍÔÚ¶ÑÖÐ. ¶¯Ì¬·ÖÅäµÃµ½µÄÄڴ渽´øÓзÖÅäÐÅÏ¢, ËùÒÔÄãÄܹ» realloc ºÍ freeµ÷ËüÃÇ.
È«¾Ö£¬¾²Ì¬ºÍ³£Á¿ÊÇ·ÖÅäÔÚÊý¾ÝÇøÖеġ£Êý¾ÝÇø°üÀ¨bssºÍ³õʼ»¯Çø¡£
¶ÑÏò¸ßÄÚ´æµØÖ·Éú³¤
Õ»ÏòµÍÄÚ´æµØÖ·Éú³¤
¶ÑºÍÕ»ÏàÏò¶øÉú£¬¶ÑºÍÕ»Ö®¼äÓиöÁÙ½çµã£¬³ÆΪstkbrk
CODE:
½ø³ÌÔÚÄÚ´æÖеÄÓ°Ïñ.
ÎÒÃǼÙÉèÏÖÔÚÓÐÒ»¸ö³ÌÐò, ËüµÄº¯Êýµ÷ÓÃ˳ÐòÈçÏÂ.
main(...) ->; func_1(...) ->; func_2(...) ->; func_3(...)
¼´: Ö÷º¯Êýmainµ÷Óú¯Êýfunc_1; º¯Êýfunc_1µ÷Óú¯Êýfunc_2; º¯Êýfunc_2µ÷Óú¯Êýfunc_3
µ±³ÌÐò±»²Ù×÷ϵͳµ÷ÈëÄÚ´æÔËÐÐ, ÆäÏà¶ÔÓ¦µÄ½ø³ÌÔÚÄÚ´æÖеÄÓ°ÏñÈçÏÂͼËùʾ.
(ÄÚ´æ¸ßÖ·)
+--------------------------------------+
| ...... | ... Ê¡ÂÔÁËһЩÎÒÃDz»ÐèÒª¹ØÐĵÄÇø
+--------------------------------------+
| env strings (»·¾³±äÁ¿×Ö´®) | \
+--------------------------------------+ \
| argv strings (ÃüÁîÐÐ×Ö´®) | \
+--------------------------------------+ \
| env pointers (»·¾³±äÁ¿Ö¸Õë) | SHELLµÄ»·¾³±äÁ¿ºÍÃüÁîÐвÎÊý±£
Ïà¹ØÎĵµ£º
Ò»
ʹÓÿâ±ØÒªÐÔ
Ìá¸ß´úÂëÖØÓÃÐÔ¡£
¶þ
¿âµÄÖÖÀࣺ
1
¾²Ì¬¿â
Ò»°ãÒÔ
*.a
ÃüÃû¡£
³ÌÐò±àÒëʱ±»¼ÓÔØ£¬´Ëºó£¬Ö»Òª³ÌÐò²»±»ÖØбàÒ룬¾²Ì¬¿â¾ÍûÓÐ×÷ÓÃÁË£¨¿ÉÒÔɾµô£©¡£
ÓÉ
ÓÚ¾²Ì¬¿âµÄ´úÂëÔÚ±àÒë¹ý³ÌÖÐÒѾ±»ÔØÈ ......
°Ñ×Ô¼º³£ÓõÄһЩlinuxÃüÁî¼Ç¼ÏÂÀ´
1. ²é¿´µ±Ç°Óû§ºÍ×é
less /etc/passwd
less /etc/group »òÕß groups ²é¿´×é
ÓÐÈË˵ÓÃÉÏÃæÄÇÁ½¸öÃüÁîµÃµ½µÄ½á¹û²»ÍêÈ«£¬Ò»Ð©ÌØÊⷽʽ½¨Á¢µÄ¾Í¿´²»µ½ÁË£¬¿É¸ÄÓÃ
getent passwd
getent group
2. ¸Ä±äÎļþµÄËùÓÐÕߺÍËùÊô×é
chown baoniu ......
×î½ü¿´ÁËһЩLinuxÃüÁîÐеÄÎÄÕ£¬ÔÚϵͳÐÅÏ¢²é¿´·½Ãæѧµ½²»ÉÙÃüÁî¡£ ÏëÆðÒÔǰд¹ýµÄһƪÆäʵLinuxÕâÑùÓøü¼òµ¥
£¬
·¢ÏÖÕâЩϵͳÐÅÏ¢²é¿´ÃüÁîÒ²¿ÉÒÔ×ܽá³öһƪССµÄ¶«Î÷À´ÁË¡£
ÁíÍâÕâÀï
»¹Óзdz£¶àµÄÃüÁ ¿ÉÒÔ×÷Ϊ²Î¿¼¡£
ϵͳ
# uname -a # ²é¿´ÄÚºË/²Ù×÷ϵͳ/CPUÐÅÏ¢
# head -n 1 /etc/issue ......
ÅäÖÃÎļþÒ»ÀÀ±í ÎļþλÖü°Ãû³Æ,×÷ÓÃ
¡¡¡¡/etc/rc.d/rc.sysinit
¡¡¡¡ÏµÍ³Æô¶¯Ê±µÄ¹«Ó÷þÎñÅäÖÃ
¡¡¡¡/etc/rc.d/rc.local
¡¡¡¡ÏµÍ³Æô¶¯Ê±µÄ±¾µØ·þÎñÅäÖÃ
¡¡¡¡/etc/bashrc¡¢/etc/profile
¡¡¡¡bash shellµÄ¹«ÓÃÅäÖÃ
¡¡¡¡/home/username/.bashrc
¡¡¡¡¸÷Óû§Ë½ÈËbash shellÅäÖÃ
¡¡¡¡/etc/securetty
¡¡¡¡Öն˰²È«ÉèÖÃ
......
Ò» £¬ÔõÑùѧϰCÓïÑÔ
ºÜ¶àÈ˶ÔѧϰCÓïÑԸе½ÎÞ´ÓÏÂÊÖ£¬¾³£ÎÊÎÒͬһ¸öÎÊÌ⣺¾¿¾¹ÔõÑùѧϰCÓïÑÔ£¿ÎÒÊÇÒ»¸ö½Ìʦ£¬ÒѾ¿ª·¢Á˺ܶàÄêµÄ³ÌÐò£¬ºÍºÜ¶à¸Õ¸ÕÆð²½µÄÈËÒ»Ñù£¬Ñ§Ï°µÄµÚÒ»¸ö¼ÆËã»úÓïÑÔ¾ÍÊÇCÓïÑÔ¡£¾¹ýÕâЩÄêµÄ¿ª·¢£¬ÎÒÉîÉîµÄÌå»áµ½CÓïÑÔ¶ÔÓÚÒ»¸ö³ÌÐòÉè¼ÆÈËÔ±¶àôµÄÖØÒª£¬Èç¹û²»¶®CÓ ......