³£¼ûµÄLinuxÎļþ²éÕÒ¼¼ÇÉ
LinuxÖвéÕÒÎļþÊÇÎÒÃÇÔÚÒ»Ñùƽ³£Ê¹ÓÃÖо³£Óöµ½µÄÐèÇó£¬ÎÞÂÛÊDzéÕÒÌض¨ÎļþÕվɲéÕÒ°üÀ¨Ìض¨ÄÚÈݵÄÎļþ£¬¶¼ÐèÒªÕÆÎÕһЩ³£ÓõÄÒªÁì¡£±¾ÎĽ«ÏÈÈÝLinuxÖвéÕÒÎļþµÄ³£ÓÃÒªÁ죬²¢¸½ÉÏÏêϸµÄ´úÂëʾÀý¹©²Î¿¼¡£
1. ʹÓÃfindÏÂÁî
findÏÂÁîÊÇLinuxϵͳÖÐ×î³£ÓõIJéÕÒÎļþµÄ¹¤¾ß£¬ÆäÓ﷨Ϊ£º
find [path] [options] [expression]
µÇ¼ºó¸´ÖÆ
[path]£ºÖ¸¶¨ÐèÒª²éÕÒµÄĿ¼·¾¶
[options]£º²éÕÒÑ¡ÏÈç-name¡¢-typeµÈ
[expression]£º¹ýÂËÌõ¼þ£¬ÈçÎļþÃû¡¢ÎļþÀàÐ͵È
ÏêϸʾÀý£º
ÔÚÄ¿½ñĿ¼²éÕÒËùÓÐÒÔ.txtΪÀ©Õ¹ÃûµÄÎļþ£º
find . -name "*.txt"
µÇ¼ºó¸´ÖÆ
ÔÚ/homeĿ¼Ï²éÕÒËùÓÐÓµÓÐÕßΪrootµÄÎļþ£º
find /home -user root
µÇ¼ºó¸´ÖÆ
2. ʹÓÃgrepÏÂÁî
grepÏÂÁîÖ÷ÒªÓÃÓÚÔÚÎı¾Êý¾ÝÖвéÕÒÌض¨×Ö·û´®£¬Ò²¿ÉÒÔÔÚÎļþÖвéÕÒ°üÀ¨Ö¸¶¨ÄÚÈݵÄÐС£Ó﷨Ϊ£º
grep [options] 'pattern' [file]
µÇ¼ºó¸´ÖÆ
[options]£º²éÕÒÑ¡ÏÈç-rµÝ¹é²éÕÒ¡¢-iºöÂÔ¾ÞϸдµÈ
‘pattern’£ºÐèÒª²éÕÒµÄÄÚÈÝ
[file]£º±»²éÕÒµÄÎļþ
ÏêϸʾÀý£º
ÔÚ/var/logĿ¼Ï²éÕÒ°üÀ¨Òªº¦×ÖerrorµÄÈÕÖ¾Îļþ£º
grep -r "error" /var/log
µÇ¼ºó¸´ÖÆ
²éÕÒÄ¿½ñĿ¼ÏÂËùÓÐÎļþÖаüÀ¨hello worldµÄÐУº
grep -r "hello world" *
µÇ¼ºó¸´ÖÆ
3. ʹÓÃlocateÏÂÁî
locateÏÂÁîÊÇÒ»ÖÖ¿ìËÙ²éÕÒÎļþµÄ¹¤¾ß£¬Ëüͨ¹ýÒ»¸öÊý¾Ý¿â¾ÙÐÐËÑË÷£¬ËÙÂʽϿ졣Ó﷨Ϊ£º
locate [pattern]
µÇ¼ºó¸´ÖÆ
[pattern]£ºÐèÒª²éÕÒµÄģʽ
ÏêϸʾÀý£º
²éÕÒϵͳÖÐËùÓаüÀ¨exampleÒªº¦×ÖµÄÎļþ£º
locate example
µÇ¼ºó¸´ÖÆ
4. ʹÓÃlsÏÂÁîÍŽáͨÅä·û
³ýÁËÉÏÊöÏÂÁîÍ⣬ÎÒÃÇ»¹¿ÉÒÔÍŽálsÏÂÁîºÍͨÅä·ûÀ´²éÕÒÎļþ¡£ÀýÈ磬²éÕÒÄ¿½ñĿ¼ÏÂËùÓÐÒÔ.logΪ×îºóµÄÎļþ£º
ls *.log
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÊÇLinuxÖвéÕÒÎļþµÄ³£ÓÃÒªÁì¼°´úÂëʾÀý£¬Äã¿ÉÒÔƾ֤²î±ðµÄÐèÇóÑ¡ÔñºÏÊʵÄÒªÁìÀ´²éÕÒÎļþ¡£Í¨¹ýÕÆÎÕÕâЩҪÁ죬¿ÉÒÔÌá¸ßÊÂÇéЧÂÊ£¬¿ìËÙ¶¨Î»ÐèÒªµÄÎļþ¡£
ÒÔÉϾÍÊdz£¼ûµÄLinuxÎļþ²éÕÒ¼¼ÇɵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡