ÔõÑù׼ȷÉèÖÃLinuxÖеÄPATHÇéÐαäÁ¿
ÔõÑù׼ȷÉèÖÃLinuxÖеÄPATHÇéÐαäÁ¿
ÔÚLinux²Ù×÷ϵͳÖУ¬ÇéÐαäÁ¿ÊÇÓÃÀ´´æ´¢ÏµÍ³¼¶±ðµÄÉèÖÃÐÅÏ¢µÄÖ÷Òª»úÖÆÖ®Ò»¡£ÆäÖУ¬PATHÇéÐαäÁ¿±»ÓÃÀ´Ö¸¶¨ÏµÍ³ÔÚÄÄЩĿ¼ÖвéÕÒ¿ÉÖ´ÐÐÎļþ¡£×¼È·ÉèÖÃPATHÇéÐαäÁ¿ÊÇÈ·±£ÏµÍ³Õý³£ÔËÐеÄÒªº¦Ò»²½¡£±¾ÎĽ«ÏÈÈÝÔõÑù׼ȷÉèÖÃLinuxÖеÄPATHÇéÐαäÁ¿£¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£
1. Éó²éÄ¿½ñPATHÇéÐαäÁ¿
ÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁî¿ÉÒÔÉó²éÄ¿½ñϵͳÖеÄPATHÇéÐαäÁ¿£º
echo $PATH
µÇ¼ºó¸´ÖÆ
ͨ¹ýÕâ¸öÏÂÁÎÒÃÇ¿ÉÒÔ¿´µ½ÏµÍ³Ä¿½ñµÄPATHÇéÐαäÁ¿ÊÇÓɶà¸öĿ¼·¾¶×é³ÉµÄ£¬ÕâЩ·¾¶ÓÃðºÅ£¨:£©ÍÑÀ뿪¡£
2. ÐÞ¸ÄPATHÇéÐαäÁ¿
ÔÝʱÐÞ¸ÄPATHÇéÐαäÁ¿
ÈôÊÇÄãÖ»ÊÇÔÝʱÐèÒªÐÞ¸ÄPATHÇéÐαäÁ¿£¬¿ÉÒÔÔÚÖÕ¶ËÖÐÖ±½ÓÊäÈëÒÔÏÂÏÂÁ
export PATH=/new/path:$PATH
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÕâÌõÏÂÁ/new/pathÌí¼Óµ½PATHÇéÐαäÁ¿µÄ×îÇ°Ãæ¡£Çë×¢ÖØ£¬ÕâÖÖÐ޸ķ½·¨Ö»ÔÚÄ¿½ñÖն˴°¿ÚÖÐÓÐÓã¬ÖØÆôºó½«»áʧЧ¡£
ÓÀÊÀÐÞ¸ÄPATHÇéÐαäÁ¿
ÈôÊÇÄãÏ£ÍûÓÀÊÀÐÔµØÐÞ¸ÄPATHÇéÐαäÁ¿£¬¿ÉÒÔ±à¼ÉèÖÃÎļþ.bashrc»ò.profile£¬Ïêϸ²Ù×÷ÈçÏ£º
·¿ª~/.bashrc»ò~/.profileÎļþ£º
vi ~/.bashrc
µÇ¼ºó¸´ÖÆ
ÔÚÎļþĩβÌí¼ÓÒÔÏ´úÂ룺
export PATH=/new/path:$PATH
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÉúÑÄÎļþ²¢Í˳ö±à¼Æ÷£»
ÊäÈëÒÔÏÂÏÂÁîʹÐÞ¸ÄÉúЧ£º
source ~/.bashrc
µÇ¼ºó¸´ÖÆ
3. ÑéÖ¤PATHÇéÐαäÁ¿ÊÇ·ñÉèÖÃ׼ȷ
ΪÁËÑéÖ¤PATHÇéÐαäÁ¿ÊÇ·ñ±»×¼È·ÉèÖ㬿ÉÒÔÊäÈëÒÔÏÂÏÂÁ
which executable_filename
µÇ¼ºó¸´ÖÆ
ÆäÖÐexecutable_filenameΪÄãÒª²éÕҵĿÉÖ´ÐÐÎļþÃû¡£ÈôÊÇÖÕ¶ËÄܹ»ÕÒµ½¸Ã¿ÉÖ´ÐÐÎļþ²¢Êä³öÆä·¾¶£¬Ôò˵Ã÷PATHÇéÐαäÁ¿ÉèÖÃ׼ȷ¡£
½áÓï
׼ȷÉèÖÃLinuxÖеÄPATHÇéÐαäÁ¿¶ÔϵͳµÄÕý³£ÔËÐÐÖÁ¹ØÖ÷Òª¡£Í¨¹ý±¾ÎÄÏÈÈݵÄÒªÁ죬Äã¿ÉÒÔÇáËɵØÐ޸ĺÍÑéÖ¤PATHÇéÐαäÁ¿¡£Ï£ÍûÕâЩÐÅÏ¢¶ÔÄãÓÐËù×ÊÖú£¬×£ÄãÔÚLinuxϵͳÖÐʹÓÃÓä¿ì£¡
Ïà¹ØÔĶÁ
[LinuxÇéÐαäÁ¿ÉèÖÃÏê½â](https://linuxtools-rst.readthedocs.io/zh_CN/latest/base/03_linuxenv.html)
[LinuxÇéÐαäÁ¿ÉèÖÃÐ޸ļ°ÉúЧҪÁì](https://cloud.tencent.com/developer/article/1781962)
²Î¿¼×ÊÁÏ
[Linux ÇéÐαäÁ¿µÄÉèÖúÍʹÓÃ](https://www.ibm.com/support/knowledgecenter/ssw_aix_72/com.ibm.aix.osdevice/env_variables.htm)
дµ½ÕâÀÎÒÃÇÒѾÏàʶÁËÔõÑù׼ȷÉèÖÃLinuxÖеÄPATHÇéÐαäÁ¿£¬²¢ÇÒÌṩÁËÏìÓ¦µÄ´úÂëʾÀý¡£Ï£Íû±¾ÎĶÔÄúÓÐËù×ÊÖú£¬Ð»Ð»ÔĶÁ£¡
ÒÔÉϾÍÊÇÔõÑù׼ȷÉèÖÃLinuxÖеÄPATHÇéÐαäÁ¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡