ѧ»áÔÚLinuxÖÐÉó²éÄ¿½ñ·¾¶
ÎÊÌ⣺ѧ»áÔÚLinuxÖÐÉó²éÄ¿½ñ·¾¶µÄÒªÁì¼°´úÂëʾÀý
ÔÚLinux²Ù×÷ϵͳÖУ¬¾³£ÐèÒªÉó²éÄ¿½ñËùÔڵķ¾¶£¬ÒÔ±ã¸üºÃµØ¶¨Î»ºÍ²Ù×÷ÎļþºÍĿ¼¡£±¾ÎĽ«ÏÈÈÝÔÚLinuxÖÐÉó²éÄ¿½ñ·¾¶µÄ¼¸ÖÖÒªÁ죬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£Ï£ÍûÄÜ×ÊÖú¶ÁÕßÔ½·¢ÊìÁ·µØÔÚLinuxÇéÐÎÖоÙÐз¾¶²Ù×÷¡£
1. ʹÓÃpwdÏÂÁî
pwdÊÇPrint Working DirectoryµÄËõд£¬ÓÃÓÚÏÔʾĿ½ñÊÂÇéĿ¼µÄÍêÕû·¾¶¡£Í¨¹ýÔÚÖÕ¶ËÊäÈëpwdÏÂÁ¼´¿ÉÏÔʾĿ½ñ·¾¶¡£
ʾÀý´úÂ룺
pwd
µÇ¼ºó¸´ÖÆ
2. ʹÓÃechoÏÂÁî
echoÏÂÁîÓÃÓÚÏÔʾһÐÐÎı¾£¬²¢¿É½«Îı¾Öض¨Ïòµ½ÎļþÖС£µ±ÍŽá$PWDÇéÐαäÁ¿Ê¹ÓÃʱ£¬Ò²¿ÉÒÔÏÔʾĿ½ñ·¾¶¡£
ʾÀý´úÂ룺
echo $PWD
µÇ¼ºó¸´ÖÆ
3. ʹÓÃreadlinkÏÂÁî
readlinkÏÂÁî¿ÉÒÔÏÔʾ·ûºÅÁ´½ÓµÄÄ¿µÄ·¾¶¡£µ±ÍŽá-fÑ¡ÏîʹÓÃʱ£¬¿ÉÒÔ»ñÈ¡Ä¿½ñ¾ø¶Ô·¾¶¡£
ʾÀý´úÂ룺
readlink -f .
µÇ¼ºó¸´ÖÆ
4. ʹÓÃdirnameÏÂÁî
dirnameÏÂÁîÓÃÓÚÈ¥µô×îºó²ã¼¶µÄ·¾¶£¬²¢Êä³öÉÏÒ»²ãµÄĿ¼¡£ÍŽá$PWDÇéÐαäÁ¿Ê¹ÓÃʱ£¬¿ÉÒÔÏÔʾĿ½ñ·¾¶¡£
ʾÀý´úÂ룺
dirname $PWD
µÇ¼ºó¸´ÖÆ
5. ʹÓÃpwdxÏÂÁî
pwdxÏÂÁî¿ÉÒÔÏÔʾָ¶¨Àú³ÌµÄÊÂÇéĿ¼¡£Í¨¹ý½«Ä¿½ñÀú³ÌµÄPID£¨Process ID£©×÷Ϊ²ÎÊýת´ï¸øpwdxÏÂÁ¼´¿ÉÏÔʾĿ½ñÀú³ÌµÄÊÂÇéĿ¼¡£
ʾÀý´úÂ룺
pwdx $(echo $$)
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÊǼ¸ÖÖÔÚLinuxÖÐÉó²éÄ¿½ñ·¾¶µÄÒªÁì¼°´úÂëʾÀý¡£Í¨¹ýÊìÁ·ÕÆÎÕÕâЩҪÁ죬½«Äܹ»Ô½·¢Àû±ãµØÔÚLinuxϵͳÖоÙÐз¾¶²Ù×÷£¬Ìá¸ßÊÂÇéЧÂÊ¡£Ï£Íû¶ÁÕßͨ¹ýʵ¼ùÔËÓÃÕâЩҪÁ죬Äܹ»ÔÚLinuxÇéÐÎÏÂÔ½·¢¼ÝÇá¾ÍÊìµØ¾ÙÐÐÎļþºÍĿ¼ÖÎÀí¡£
ÒÔÉϾÍÊÇѧ»áÔÚLinuxÖÐÉó²éÄ¿½ñ·¾¶µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡