Ã÷È·LinuxÖеÄPATHÇéÐαäÁ¿
ÎÊÌ⣺ÉîÈë̽ÌÖLinuxÖеÄPATHÇéÐαäÁ¿
ÔÚLinuxϵͳÖУ¬PATHÇéÐαäÁ¿ÊÇÒ»ÏîÖ÷ÒªµÄÉèÖÃÏËüÖ¸¶¨ÁËϵͳÔÚÄÄЩĿ¼ÖÐÑ°ÕÒ¿ÉÖ´ÐгÌÐò¡£ÏàʶºÍ׼ȷÉèÖÃPATHÇéÐαäÁ¿²»µ«¿ÉÒÔÌá¸ßϵͳµÄÔËÐÐЧÂÊ£¬»¹ÄÜ×èֹһЩ²»ÐëÒªµÄÎÊÌâºÍ¹ýʧ¡£±¾ÎĽ«ÉîÈë̽ÌÖLinuxÖеÄPATHÇéÐαäÁ¿£¬²¢Í¨¹ýÏêϸµÄ´úÂëʾÀýÀ´×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·¡£
ʲôÊÇPATHÇéÐαäÁ¿
PATHÇéÐαäÁ¿ÊÇLinuxϵͳÖÐÓÃÀ´Ö¸¶¨¿ÉÖ´ÐгÌÐòËùÔÚĿ¼µÄÒ»ÖÖÇéÐαäÁ¿¡£µ±Óû§ÔÚÖÕ¶ËÊäÈëÒ»¸öÏÂÁîʱ£¬ÏµÍ³»áÔÚPATHÇéÐαäÁ¿Ö¸¶¨µÄĿ¼ÖвéÕÒ¶ÔÓ¦µÄ¿ÉÖ´ÐгÌÐò£¬²¢Ö´ÐÐËü¡£ÈôÊÇÔÚPATHÇéÐαäÁ¿ÖÐÕÒ²»µ½¶ÔÓ¦µÄ¿ÉÖ´ÐгÌÐò£¬ÏµÍ³½«»áÌáÐÑ¡°ÏÂÁîδÕÒµ½¡±µÄ¹ýʧ¡£
Éó²éÄ¿½ñPATHÇéÐαäÁ¿
ÒªÉó²éÄ¿½ñϵͳµÄPATHÇéÐαäÁ¿£¬¿ÉÒÔÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁ
echo $PATH
µÇ¼ºó¸´ÖÆ
ϵͳ»á·µ»ØÒ»¸ö°üÀ¨¶à¸öĿ¼·¾¶µÄ×Ö·û´®£¬ÕâЩ·¾¶¾ÍÊÇϵͳÔÚ²éÕÒ¿ÉÖ´ÐгÌÐòʱÒÀ´ÎËÑË÷µÄĿ¼¡£
ÐÞ¸ÄPATHÇéÐαäÁ¿
ÈôÊÇÓû§ÐèÒªÌí¼ÓеÄĿ¼·¾¶µ½PATHÇéÐαäÁ¿ÖУ¬¿ÉÒÔͨ¹ýexportÏÂÁîÀ´ÊµÏÖ¡£ºÃ±È£¬¼ÙÉèÓû§Ï£Íû½«×Ô½ç˵µÄĿ¼/usr/local/myprogram¼ÓÈëµ½PATHÇéÐαäÁ¿ÖУ¬¿ÉÖ´ÐÐÒÔϲÙ×÷£º
export PATH=$PATH:/usr/local/myprogram
µÇ¼ºó¸´ÖÆ
ÕâÐÐÏÂÁîµÄ¼ÄÒåÊǽ«ÔÓеÄPATHÇéÐαäÁ¿ÖµºÍÐÂÔöµÄĿ¼·¾¶¾ÙÐÐÆ´½Ó£¬´Ó¶øʵÏÖ¶ÔPATHÇéÐαäÁ¿µÄÐ޸ġ£
Ïêϸ´úÂëʾÀý
½ÓÏÂÀ´Í¨¹ýÒ»¸öÏêϸµÄ´úÂëʾÀýÀ´ÑÝʾÔõÑùʹÓÃPATHÇéÐαäÁ¿¡£¼ÙÉèÎÒÃÇÓÐÒ»¸öÃûΪhello_worldµÄ¿ÉÖ´ÐгÌÐò£¬´æ·ÅÔÚ/home/user/binĿ¼Ï¡£ÎªÁËÈÃϵͳÄܹ»ÔÚí§ÒâλÖÃÖ´ÐиóÌÐò£¬ÎÒÃÇÐèÒª½«/home/user/binÌí¼Óµ½PATHÇéÐαäÁ¿ÖС£
Ê×ÏÈ£¬ÎÒÃÇ¿ÉÒÔ½¨ÉèÒ»¸ö¼òÆÓµÄhello_world³ÌÐò£¬´úÂëÈçÏ£º
#include <stdio.h> int main() { printf("Hello, World! "); return 0; }
µÇ¼ºó¸´ÖÆ
±àÒëÕâ¸ö³ÌÐò²¢½«¿ÉÖ´ÐÐÎļþÉúÑĵ½/home/user/binĿ¼Ï£¬ÃüÃûΪhello_world£º
gcc hello_world.c -o /home/user/bin/hello_world
µÇ¼ºó¸´ÖÆ
½Ó×Å£¬½«/home/user/binÌí¼Óµ½PATHÇéÐαäÁ¿ÖУº
export PATH=$PATH:/home/user/bin
µÇ¼ºó¸´ÖÆ
ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔÔÚí§ÒâλÖÃÖ´ÐÐhello_world³ÌÐò£º
hello_world
µÇ¼ºó¸´ÖÆ
ϵͳӦ¸Ã»áÊä³öHello, World!£¬ÕâÅú×¢PATHÇéÐαäÁ¿ÒѾ׼ȷÉèÖá£
×ܽá
ͨ¹ý±¾ÎĵÄÏÈÈݺʹúÂëʾÀý£¬ÐÅÍжÁÕ߶ÔLinuxÖеÄPATHÇéÐαäÁ¿ÓÐÁ˸üÉîÈëµÄÃ÷È·¡£×¼È·ÉèÖúÍʹÓÃPATHÇéÐαäÁ¿¹ØÓÚϵͳÖÎÀíÕߺͿª·¢ÕßÀ´Ëµ¶¼ÊÇÖÁ¹ØÖ÷ÒªµÄ£¬Ï£Íû±¾ÎÄÄܹ»×ÊÖú¶ÁÕ߸üºÃµØÕÆÎÕÕâ¸öÒªº¦µÄÇéÐαäÁ¿¡£
ÒÔÉϾÍÊÇÃ÷È·LinuxÖеÄPATHÇéÐαäÁ¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡