linux鏃ュ父甯哥敤鍛戒护鏁寸悊

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux鏃ュ父甯哥敤鍛戒护鏁寸悊相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/des' title='des'>des   鐢ㄦ硶   boot   鏂囦欢鐩綍   status   diff   鏂瑰紡   绋嬪簭   缁撴潫   

涓€銆佺洰褰曞垏鎹紝鍒涘缓锛屽垹闄わ紝鍒楀嚭鐩綍涓嬬殑鍐呭

锛?锛塩d鍛戒护

銆€鏍煎紡锛歝d [鐩綍]

  • cd ~ 锛氳〃绀哄綋鍓嶇敤鎴风洰褰?/li>
  • cd / 锛氬垏鎹㈠埌鏍圭洰褰?/li>
  • cd - 锛氬垏鎹㈠埌涓婁竴娆¤闂殑鐩綍
  • cd .. 锛氬垏鎹㈠埌涓婁竴绾х洰褰?/li>
  • cd 锛氱己鐪佸綋鍓嶇敤鎴风洰褰?/li>

锛?锛塸wd鍛戒护锛歱wd涓昏鐢ㄦ潵鏌ョ湅褰撳墠鎵€鍦ㄧ洰褰曘€?/p>

锛?锛夊垱寤虹洰褰?/p>

鍒涘缓鐩綍浣跨敤mkdir鍛戒护锛屾湁濡備笅涓や釜甯哥敤鍙傛暟锛?/p>

  • -p 锛氳〃绀虹埗鐩綍涓嶅瓨鍦ㄧ殑鎯呭喌涓嬪厛鍒涘缓鐖剁洰褰?/li>
  • -v 锛氭樉绀哄懡浠ょ殑鎵ц杩囩▼涓殑璇︾粏淇℃伅

渚嬪锛歮kdir -pv /jason/hello 鍏堝垱寤簀ason鐩綍锛岀劧鍚庡湪Jason閲岄潰鍒涘缓hello鐩綍

锛?锛夊垹闄ゆ枃浠舵垨鑰呯洰褰?/p>

rmdir鍛戒护锛氬垹闄ょ┖鐨勭洰褰曘€傛湁濡備笅涓や釜鍙傛暟锛?/p>

  • -p 锛氬垹闄ゆ寚瀹氱洰褰曚互鍙婁笂绾х洰褰?/li>
  • -v 锛氭樉绀哄垹闄ょ洰褰曠殑鎵ц杩囩▼

渚嬪锛歳mdir -pv /jason/hello/world锛岃〃绀哄皢world鐩綍鍙婂叾涓婄骇鐩綍鍒犻櫎锛岀洿鍒版妸jason鐩綍鍒犻櫎銆?/p>

涔熷彲浠ヤ娇鐢╮m鍒犻櫎鏂囦欢鎴栬€呯洰褰曪紝璇疯皑鎱庝娇鐢ㄣ€?/p>

rm鍛戒护锛氬垹闄ゆ枃浠舵垨鑰呯洰褰?/p>

鏍煎紡锛歳m [鏂囦欢鎴栬€呯洰褰昡銆€銆€

  • -f 琛ㄧず寮哄埗鍒犻櫎鏂囦欢鎴栬€呯洰褰?/li>
  • -r 琛ㄧず閫掑綊鍒犻櫎鎵€鏈夌洰褰曞強鍏舵枃浠?/li>
  • -i銆€琛ㄧず鍒犻櫎鍓嶉渶瑕佽繘琛岀‘璁?/li>

锛?锛夋煡鐪嬪綋鍓嶇洰褰曚笅鏈夊摢浜涙枃浠?/p>

浣跨敤ls鎴栬€卨l鍛戒护鏌ョ湅褰撳墠鐩綍涓嬫湁鍝簺鏂囦欢銆?/p>

ls锛坙ist锛夊懡浠わ細鍒楀嚭鐩綍鍐呭銆?/p>

鏍煎紡锛歭s [鍙傛暟]

ls -a鎴?all琛ㄧず鍒楀嚭鎵€鏈夋枃浠跺拰鐩綍锛屼互鐐瑰紑濮嬬殑鏄殣钘忔枃浠讹紝渚嬪锛?bash_history銆?/p>

  • ls -l 浣跨敤璇︾粏鏍煎紡鍒楄〃
  • ls -t 鐢ㄦ枃浠跺拰鐩綍鐨勬洿鏀规椂闂存帓搴?/li>
  • ls -r 鍙嶅悜鎺掑簭

涓夈€佷笂浼犱笅杞芥枃浠?/h3>

锛?锛塼ouch鍛戒护锛氬湪褰撳墠鐩綍鍒涘缓涓€涓枃浠讹紝渚嬪锛歵ouch 1.txt

锛?锛塺z鍛戒护涓婁紶鏂囦欢

涓婁紶鏂囦欢锛氭湁涓ょ鏂瑰紡锛岀涓€绉嶇洿鎺ユ嫋鍏shell锛岀浜岀浣跨敤rz鍛戒护锛屼箣鍚庡脊绐楅€夋嫨闇€瑕佷紶鐨勬枃浠跺嵆鍙€?/p>

锛?锛塻z鍛戒护涓嬭浇鏂囦欢

浠巐inux涓笅杞芥枃浠跺埌鏈湴浣跨敤sz鍛戒护锛屽 sz 鏂囦欢鍚? 锛岀劧鍚庝細寮圭獥閫夋嫨淇濆瓨璺緞鍗冲彲銆?/p>


鍏朵腑zxvf鍚箟鍒嗗埆濡備笅: z: 銆€銆€gzip銆€銆€ 鍘嬬缉鏍煎紡 x: 銆€銆€extract銆€ 瑙e帇 v:銆€銆€ verbose銆€銆€璇︾粏淇℃伅 f: 銆€銆€file(file=archieve)銆€鏂囦欢

锛?锛塮ilename.zip鐨勮В鍘嬶紝 unzip鍛戒护锛氳В鍘?zip鏂囦欢鍛戒护锛屼緥濡傦細unzip file1.zip

unzip filename.zip
鍙傛暟濡備笅
-v 鏌ョ湅鏂囦欢鐩綍鍒楄〃锛屼絾鏄笉瑙e帇
-d 灏嗘枃浠惰В鍘嬪埌鎸囧畾鐩綍涓?-n 涓嶈鐩栧師鏉ュ凡缁忓瓨鍦ㄧ殑鏂囦欢
-o 瑕嗙洊宸插瓨鍦ㄧ殑鏂囦欢骞朵笖涓嶉渶瑕佺敤鎴风‘璁?

锛?锛塯zip鍛戒护锛氱敤浜庤В鍘嬬缉鏂囦欢锛屽悗缂€鍚嶄负.gz鐨勫帇缂╂枃浠?/p>

渚嬪锛歡zip file锛屽帇缂╄繃鍚庡彉涓篺ile.gz锛屼絾鏄師鏂囦欢瑕佹秷澶便€傝繕鍙互鍦ㄥ帇缂╄繃绋嬩腑鎸囧畾鍘嬬缉鐨勭櫨鍒嗘瘮锛実zip鍛戒护鎻愪緵浜?-9绾х殑鍘嬬缉姣旓紝锛戠殑鍘嬬缉姣旀渶宸紝浣嗘槸鍘嬬缉閫熷害姣旇緝蹇紝鑰?鐨勫帇缂╂瘮鏈€濂斤紝浣嗘槸閫熷害姣旇緝鎱紝榛樿鐨勭骇鍒槸6銆?/p>

渚嬪锛歡zip -1 file锛実zip涓嶄絾鍙互鍘嬬缉锛岃繕鍙互瑙e帇锛屼緥濡傦細gzip -d file.gz

锛?锛墇cat鍛戒护锛氭煡鐪嬪帇缂╂枃浠跺唴瀹瑰懡浠わ紝渚嬪锛歾cat file.gz

锛?锛塮ilename.tar.bz2鐨勮В鍘嬶細tar -jxvf filename.tar.bz2

j: 銆€bzip2 鍘嬬缉鏍煎紡

鍏跺畠閫夐」鍜宼ar.gz瑙e帇鍚箟鐩稿悓

锛?锛塮ilename.tar.xz鐨勮В鍘嬶細 tar -Jxvf filename.tar.xz 锛屾敞鎰廕澶у啓銆?/p>

锛?锛塮ilename.tar.Z鐨勮В鍘嬶細 tar -Zxvf filename.tar.Z 锛屾敞鎰廧澶у啓銆?/p>

鍏充簬tar鐨勮缁嗗懡浠ゅ彲浠ヤ娇鐢ㄥ府鍔╁懡浠わ細tar --help 鎴栬€卪an tar

鍙傝€冨崥鏂囷細https://www.cnblogs.com/cursorhu/p/5891699.html


[root@mail logs]# free -h total used free shared buff/cache available Mem: 7.6G 6.6G 657M 1.3M 435M 804M Swap: 0B 0B 0B

閲婁箟锛?/strong>

Mem锛氬唴瀛樹娇鐢ㄦ儏鍐点€?br> Swap锛氫氦鎹㈢┖闂达紙铏氭嫙鍐呭瓨锛変娇鐢ㄦ儏鍐点€?br> total锛氱郴缁熸€诲叡鍙敤鐗╃悊鍐呭瓨銆佷氦鎹㈢┖闂村ぇ灏忋€?br> used锛氬凡缁忚浣跨敤鐨勭墿鐞嗗唴瀛樸€佷氦鎹㈢┖闂村ぇ灏忋€?br> free锛氬墿浣欏彲鐢ㄧ墿鐞嗗唴瀛樸€佷氦鎹㈢┖闂村ぇ灏忋€?br> shared锛氳鍏变韩浣跨敤鐨勭墿鐞嗗唴瀛樺ぇ灏忋€?br> buff/cache锛氳 buffer 鍜?cache 浣跨敤鐨勭墿鐞嗗唴瀛樺ぇ灏忋€?br> available锛氳繕鍙互琚簲鐢ㄧ▼搴忎娇鐢ㄧ殑鐗╃悊鍐呭瓨澶у皬銆?/p>

甯歌浣跨敤鏂规硶锛?/p>

free -h銆€銆€銆€銆€銆€銆€//浠ユ洿鍙嬪ソ鐨勬柟寮忔樉绀猴紝浼氫互K銆丮銆丟涓哄崟浣嶆潵鏄剧ず
free -h -s 3銆€銆€ //浠ヤ竴瀹氭椂闂撮棿闅旈噸澶嶇殑杈撳嚭锛岃繖涓懡浠ゆ槸姣?绉掕緭鍑轰竴娆?

锛?锛塸s 鍛戒护

ps鍛戒护锛氾紙process status锛夛紝鎻愪緵瀵硅繘绋嬬殑涓€娆℃€ф煡鐪嬨€備互鍙婃墽琛宲s鍛戒护鏃堕偅涓椂鍒荤殑杩涚▼淇℃伅

鏍煎紡锛歱s[鍙傛暟]

-e 銆€銆€姝ゅ弬鏁版樉绀烘墍鏈夌▼搴?/p>

-f銆€銆€ 鏄剧ずuid锛宲pid锛宑锛宻time鐨勬爮浣嶄俊鎭?/p>

甯歌鐢ㄦ硶锛歱s -ef | grep tomcat 鏌ョ湅tomcat杩涚▼鐨勬儏鍐点€?/p>

ps 鍛戒护鍙互鏌ョ湅绯荤粺涓悇涓繘绋嬬殑杩愯鎯呭喌锛屽寘鎷簡杩涚▼鍗犵敤鐨勫唴瀛橈紝%MEM 鍒楀氨鏄悇涓繘绋嬬殑鍐呭瓨鍗犵敤鐧惧垎姣斻€?/p>

[root@mail logs]# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0 191160  2760 ?        Ss   Aug13  12:54 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root         2  0.0  0.0      0     0 ?        S    Aug13   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Aug13   1:58 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   Aug13   0:00 [kworker/0:0H]

浣跨敤man ps鏌ョ湅ps鍛戒护鐨勭敤娉曘€?/p>

锛?锛塼op鍛戒护

浣跨敤top鍛戒护锛屽彲浠ユ煡鐪嬫鍦ㄨ繍琛岀殑杩涚▼鍜岀郴缁熻礋杞戒俊鎭紝鍖呮嫭cpu璐熻浇銆佸唴瀛樹娇鐢ㄣ€佸悇涓繘绋嬫墍鍗犵郴缁熻祫婧愮瓑銆?/p>

[root@mail logs]# top
top - 10:45:11 up 81 days,  2:09,  9 users,  load average: 0.07, 0.06, 0.08
Tasks: 130 total,   2 running, 128 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.3 us,  1.2 sy,  0.0 ni, 97.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8009184 total,   588644 free,  6912424 used,   508116 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   800748 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                       
24238 root      10 -10  186060  59720   5404 S   1.3  0.7 585:01.24 AliYunDun                                                                                                                                 
 1326 root      20   0 3261644 544324      0 S   0.7  6.8 125:18.83 java                                                         

top鍛戒护浠ヤ竴瀹氶鐜囧姩鎬佹洿鏂拌繖浜涚粺璁′俊鎭紝鎸塹閫€鍑恒€?br> 鍙嶆槧绯荤粺鍐呭瓨浣跨敤鐘跺喌鐨勬槸涓嬮潰杩欎袱琛岋細

KiB Mem :  8009184 total,   588644 free,  6912424 used,   508116 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   800748 avail Mem 

Mem琛屾槸鐗╃悊鍐呭瓨浣跨敤鎯呭喌锛屽垎鍒槸锛氱墿鐞嗗唴瀛樻€婚噺锛屽凡浣跨敤鐨勭墿鐞嗗唴瀛樻€婚噺锛岀┖闂茬墿鐞嗗唴瀛樻€婚噺锛岀敤浣滃唴鏍哥紦瀛樺尯鐨勫唴瀛橀噺銆?br> Swap琛屾槸浜ゆ崲鍖轰娇鐢ㄦ儏鍐碉紝鍒嗗埆鏄細浜ゆ崲鍖烘€婚噺锛屽凡浣跨敤鐨勪氦鎹㈠尯鎬婚噺锛岀┖闂蹭氦鎹㈠尯鎬婚噺锛岀紦鍐茬殑浜ゆ崲鍖烘€婚噺銆?br> Top鍛戒护鐨勪笅渚у尯鍩熸樉绀虹殑鏄悇涓繘绋嬩娇鐢ㄧ殑绯荤粺璧勬簮缁熻淇℃伅锛屽唴瀛樼浉鍏冲垪濡備笅锛?/p>

  • VIRT鍒楋細杩涚▼浣跨敤鐨勮櫄鎷熷唴瀛樻€婚噺锛屽崟浣峩b銆?/li>
  • RES鍒楋細杩涚▼浣跨敤鐨勩€佹湭琚崲鍑虹殑鐗╃悊鍐呭瓨澶у皬锛屽崟浣峩b銆?/li>
  • SHR鍒楋細鍏变韩鍐呭瓨澶у皬锛屽崟浣峩b銆?/li>
  • %MEM 鍒楋細杩涚▼浣跨敤鐨勭墿鐞嗗唴瀛樼櫨鍒嗘瘮銆?/li>

鍦ㄨ繍琛宼op鐨勬椂鍊欙紝鍙互鎸変笅鏂逛究鐨勫揩鎹烽敭锛?br> M锛氳〃绀哄皢缁撴灉鎸夌収鍐呭瓨锛圡EM锛変粠楂樺埌浣庤繘琛岄檷搴忔帓鍒楋紱
P锛氳〃绀哄皢缁撴灉鎸夌収CPU浣跨敤鐜囦粠楂樺埌浣庤繘琛岄檷搴忔帓鍒楋紱
1锛氬綋鏈嶅姟鍣ㄦ嫢鏈夊涓猚pu鐨勬椂鍊欏彲浠ヤ娇鐢ㄢ€?鈥濆揩鎹烽敭鏉ュ垏鎹㈡槸鍚﹀睍绀烘樉绀哄悇涓猚pu鐨勮缁嗕俊鎭紱

锛?锛塿mstat鍛戒护

vmstat 鏄疺irtual Meomory Statistics锛堣櫄鎷熷唴瀛樼粺璁★級鐨勭缉鍐欙紝鍙鎿嶄綔绯荤粺鐨勮櫄鎷熷唴瀛樸€佽繘绋嬨€丆PU娲诲姩杩涜鐩戞帶锛屾槸瀵圭郴缁熺殑鏁翠綋鎯呭喌杩涜鐨勭粺璁°€?/p>

[root@mail logs]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 616780  17824 473136    0    0    32    22    3    2  1  1 98  0  0

涓庡唴瀛樹娇鐢ㄦ儏鍐电浉鍏崇殑鏄痬emory鍒楀拰swap鍒楋紝鎴戜滑鍙湅杩欎袱鍒椼€?/p>

memory鍒?/strong>
swpd锛氫娇鐢ㄧ殑铏氭嫙鍐呭瓨澶у皬銆?br> free锛氱┖闂茬墿鐞嗗唴瀛樺ぇ灏忋€?br> buff锛歜uffer cache鍐呭瓨澶у皬銆?br> cache锛歱age cache鐨勫唴瀛樺ぇ灏忋€?/p>

swap鍒?/strong>
si锛氭瘡绉掍粠浜ゆ崲鍖鸿鍏ュ埌鍐呭瓨鐨勫ぇ灏忥紝鐢辩鐩樿皟鍏ュ唴瀛橈紙鍗曚綅锛歬b/s锛?br> so锛氭瘡绉掍粠鍐呭瓨鍐欏嚭鍒颁氦鎹㈠尯鐨勫ぇ灏忥紝鐢卞唴瀛樿皟鍏ョ鐩橈紙鍗曚綅锛歬b/s锛?/p>

甯歌鐢ㄦ硶锛?/strong>

vmstat 1銆€銆€銆€銆€//姣忛殧1s鎵撳嵃涓€娆?vmstat 1 5銆€銆€銆€//姣忛殧1绉掓墦鍗颁竴娆★紝鎵撳嵃浜旀
vmstat -s銆€銆€銆€銆€//鏄剧ず鍐呭瓨鐩稿叧缁熻淇℃伅鍙婂绉嶇郴缁熸椿鍔ㄦ暟閲?

锛?锛塳ill鍛戒护

鐢ㄤ簬鏉€姝绘墽琛屼腑鐨勭▼搴忔垨杩涚▼銆?/p>

鏍煎紡锛歬ill 鍙傛暟

kill -9 琛ㄧず寮哄埗缁堟绋嬪簭鐨勮繍琛?/p>

浣跨敤锛歬ill -9 pid pid鏄寚ps -ef 涓垪鍑烘潵鐨刾id 鍗崇▼搴忕殑id鍙枫€?/p>

锛?锛塪u -sh 鍛戒护

浣滅敤锛氭煡鐪嬬洰褰曠殑鐪熷疄澶у皬
璇硶锛歞u -sh 鐩綍璺緞
閫夐」鍚箟锛?/p>

-s锛歴ummaries锛屽彧鏄剧ず姹囨€荤殑澶у皬
-h锛氳〃绀轰互楂樺彲璇绘€х殑褰㈠紡杩涜鏄剧ず


https://www.cnblogs.com/asxe/p/9317811.html

锛?锛塼ime鍛戒护

鐢ㄤ簬璁$畻涓€涓▼搴忚繍琛岀殑鏃堕棿锛岀▼搴忚繍琛岀粨鏉熸椂锛岃緭鍑轰互涓嬩笁涓弬鏁帮細銆€

user锛氳〃绀虹▼搴忓湪鐢ㄦ埛鎬佷笅鎵ц鐨勬椂闂寸殑鎬诲拰
system锛氳〃绀虹▼搴忔墽琛屽畬鎴愯姳璐圭殑绯荤粺CPU鏃堕棿锛屽嵆绋嬪簭鍦ㄦ牳蹇冩€佷腑鎵ц鏃堕棿鎬诲拰
real锛氳〃绀轰粠寮€濮嬪埌缁撴潫鐨勫疄闄呰姳璐规椂闂?

瀹冭兘鍋氱殑涓嶄粎浠呮槸娴嬮噺杩愯鏃堕棿锛岃繕鍙互娴嬮噺鍐呭瓨銆両/O绛夌殑浣跨敤鎯呭喌銆備竴涓▼搴忓湪杩愯鏃朵娇鐢ㄧ殑绯荤粺璧勬簮閫氬父鍖呮嫭CPU銆丮emory鍜孖/O绛夛紝鍏朵腑CPU璧勬簮鐨勭粺璁″寘鎷疄闄呬娇鐢ㄦ椂闂达紙real time锛夈€佺敤鎴锋€佷娇鐢ㄦ椂闂达紙the process spent in user mode锛夈€佸唴鏍告€佷娇鐢ㄦ椂闂达紙the process spent in kernel mode锛夈€?/p>


鏍煎紡锛歮ore 鏂囦欢鍚?鐩稿叧鎿嶄綔锛?Enter 銆€銆€琛ㄧず鍚戜笅n琛岋紝榛樿涓?琛岋紝鍙互鑷畾涔夈€?绌烘牸閿€€銆€琛ㄧず鍚戜笅婊氬姩涓€灞?鎴栬€呮寜Ctrl+f b銆€銆€銆€銆€ 杩斿洖涓婁竴灞忔垨鑰卌trl+B q銆€銆€銆€銆€ 閫€鍑簃ore 閫傜敤鍦烘櫙锛氶€傚悎鍐呭杈冨鐨勬枃浠?

锛?锛塴ess鍛戒护锛氬垎椤垫樉绀烘枃浠跺唴瀹癸紝鎿嶄綔鏇村姞璇︾粏锛屽姛鑳芥洿鍔犲己澶?/p>

鏍煎紡锛歭ess [鍙傛暟] 鏂囦欢
-m 銆€銆€鏄剧ず绫讳技more鍛戒护鐨勭櫨鍒嗘瘮
-N銆€銆€ 鏄剧ず姣忚鐨勮鍙凤紝涓€瀹氳鏄ぇ鍐橬

鐩稿叧鎿嶄綔锛?绌烘牸閿?鍓嶈繘涓€椤垫垨鑰卲age down
b銆€銆€銆€銆€鍚庨€€涓€椤垫垨page up
d銆€銆€銆€銆€鍓嶈繘鍗婇〉
u銆€銆€銆€銆€鍚庨€€鍗婇〉
鍥炶溅閿€€銆€鍓嶈繘涓€琛屾垨鑰呭悜涓嬫柟鍚戦敭
y銆€銆€銆€銆€ 鍚庨€€涓€琛屾垨鑰呭悜涓婃柟鍚戦敭
/瀛楃涓层€€銆€鍚戜笅鎼滅储
?瀛楃涓层€€銆€鍚戜笂鎼滅储
v:銆€銆€銆€銆€銆€杩涘叆vim缂栬緫鍣?宸﹀彸鏂瑰悜閿€€銆€鐩稿綋浜庢按骞虫粴鍔ㄦ潯

q銆€銆€銆€銆€銆€銆€ 閫€鍑簂ess

锛?锛塼ail鍛戒护

鐢ㄤ簬鏄剧ず鎸囧畾鏂囦欢鏈熬鍐呭锛屼笉鎸囧畾鏂囦欢鏃讹紝浣滀负杈撳叆淇℃伅杩涜澶勭悊銆?/p>

鏍煎紡锛歵ail  鍙傛暟 鏂囦欢鍚?-n銆€銆€鏄剧ず琛屾暟
-f銆€銆€寰幆璇诲彇
& 銆€琛ㄧず鍦ㄥ悗鍙拌繍琛岋紝鍚﹀垯鍗犵敤缁堢

渚嬪 tail -100f stdout.log 琛ㄧず寰幆瀹炴椂璇诲彇鏃ュ織锛屾瘡娆℃樉绀?00琛?
ctrl+c 閫€鍑簍ail

锛?锛夌閬搢鍜実rep鍛戒护

linux涓彁渚涚閬撶鍙封€渱鈥濓紝浣滅敤鏄懡浠?鐨勮緭鍑哄唴瀹逛綔涓哄懡浠?鐨勮緭鍏ュ唴瀹广€傞€氬父涓巊rep鍛戒护涓€璧蜂娇鐢ㄣ€?/p>

鏍煎紡锛氬懡浠? |鍛戒护2

grep鍛戒护锛氬叏绉颁负global regular expression print,琛ㄧず鍏ㄥ眬姝e垯琛ㄨ揪寮?/p>

鍔熻兘锛氱敤浜庤繃婊ゆ垨鑰呮悳绱㈢壒瀹氱殑瀛楃銆傚彲浠ョ粨鍚堟ā绯婃悳绱竴璧蜂娇鐢紝鍗佸垎鐏垫椿銆?/p>

鏍煎紡 锛歡rep [option] pattern [file]

-i 鎴栬€?-ignore-case 琛ㄧず蹇界暐澶у皬鍐欏尯鍒€?/p>

渚嬪锛氭煡鐪媕ason.txt鏂囦欢涓惈鏈塰ello瀛楃鐨勪俊鎭?/p>

grep -r h* jason.txt

鍙互涓庡叾浠栧懡浠や竴璧蜂娇鐢細more install.log | grep -i man

grep涓昏鏄敤浜庢悳绱㈢壒瀹氬瓧绗︼紝閰嶅悎姝e垯琛ㄨ揪寮忎娇鐢ㄩ潪甯哥殑鏂逛究鍜屽己澶с€?/p>


鍏€佹枃浠惰緭鍑猴紝姣旇緝锛岀粺璁★紝鎺掑簭

锛?锛塭cho鍛戒护

鍦╨inux涓富瑕佺敤浜庡悜鏂囦欢涓緭鍏ュ拰杈撳嚭鍐呭锛屾槸鍗曡杩藉姞锛屼篃鍙互娓呯┖鏂囦欢鍐呭銆?/p>

>鏄鐩栨簮鏂囦欢鍐呭锛?code>>>鏄湪婧愭枃浠跺悗闈㈣拷鍔犲唴瀹癸紝杩藉姞鐨勫唴瀹瑰湪涓嬩竴琛屾樉绀恒€?/p>

娓呯┖鏂囦欢鍐呭鏃讹細echo "" >jason.txt 杩欐椂鏂囦欢閲岄潰杩樻槸鏈夊唴瀹瑰彧涓嶈繃鏄┖琛岃€屽凡銆?/p>

锛?锛塪iff鍛戒护

diff鍛戒护鑳藉姣旇緝涓や釜鏂囦欢鐨勫樊寮傦紝鏈夊灏戝唴瀹逛笉涓€鏍凤紝diff鍛戒护鐨勭涓€涓弬鏁拌瑙嗕负鏃ф枃浠惰€岀浜屼釜鍙傛暟琚涓烘柊鏂囦欢銆?/p>

渚嬪锛歞iff hong.txt hong_new.txt 缁撴灉涓嚭鐜?鈥?lt;鈥樹唬琛ㄥ垹闄ょ殑琛岋紝鑰屸€?gt;鈥樹唬琛ㄦ柊澧炵殑琛屻€?/p>

锛?锛墂c鍛戒护

鐢ㄤ簬瀵规枃浠剁殑琛屾暟銆佸崟璇嶆暟鍜屽瓧绗︽暟杩涜缁熻銆傚父鐢ㄥ弬鏁板涓嬶細

  • -l 琛ㄧず鏄剧ず琛屾暟

  • -w 琛ㄧず鏄剧ず鍗曡瘝鏁?/p>

  • -m 琛ㄧず鏄剧ず瀛楃鏁?/p>

濡傛灉鏄嫳鏂囧瓧绗︼紝鍒欐瘡涓崟璇嶈鏁伴兘姣斿疄闄呭涓€涓瓧绗︼紝涓枃鍒欐槸涓€涓瓧琛ㄧず4涓瓧绗︺€?/p>

wc榛樿鎯呭喌涓嬫槸鍏ㄩ儴鏄剧ず琛屾暟锛屽崟璇嶆暟锛屽瓧绗︽暟銆?/p>

锛?锛塻ort鍛戒护

鑳藉瀵规枃浠跺唴瀹规垨鑰呮煡璇㈢粨鏋滆繘琛屾帓搴忋€?/p>

鍙傛暟濡備笅锛?/p>

  • -f銆€銆€琛ㄧず蹇界暐澶у皬鍐欐帓搴?/li>
  • -r銆€銆€琛ㄧず鍙嶅悜鎺掑簭
  • -t銆€銆€鎸囧畾鍒嗛殧绗?/li>
  • -k銆€銆€浠ョ鍑犱釜鍖洪棿杩涜鎺掑簭锛屽悗闈㈠姞鏁板瓧

鏇村鍙傛煡鐪嬪府鍔╂枃妗o紝man sort


鍗併€佷娇鐢ㄦ妧宸?/h3>

锛?锛塩trl+c鍛戒护锛氬綋鎯宠寮哄埗閫€鍑烘搷浣滄椂锛屼娇鐢╟trl+c鍛戒护銆?/p>

锛?锛塰istory 鍛戒护锛氫娇鐢╤istory 鍛戒护鏌ョ湅浣跨敤杩囩殑鍛戒护璁板綍銆?/p>

锛?锛塩trl+r鍛戒护锛氬揩閫熸悳绱娇鐢ㄨ繃鐨勫懡浠わ紝鎸塭nter閿揩閫熸墽琛岋紝鎸塼ab閿皢鎼滅储鍒扮殑鍛戒护瀹氫綅鍦ㄥ懡浠よ涓娿€?/p>

锛?锛塹 鍛戒护锛氭寜q閫€鍑虹浉鍏虫搷浣溿€?/p>

锛?锛塼ab閿細鎸塼ab閿揩閫熻ˉ鍏ㄥ懡浠ゃ€?/p>

锛?锛塩lear鍛戒护锛氭竻灞忓懡浠ゃ€?/p>


鍗佷竴銆亁shell鏃ュ父璁剧疆

锛?锛夌洰鍓嶈嚜宸辫缃殑鏄紝榧犳爣宸﹂敭閫夋嫨鍐呭鍗冲鍒跺唴瀹癸紝鐐瑰嚮鍙抽敭鍗崇矘璐存墍澶嶅埗鐨勫唴瀹癸紝鎸変腑闂存粴杞敭寮瑰嚭鑿滃崟銆?/p>

锛?锛夊叾浠栧揩鎹风敤娉曡繕鍦ㄦ帰绱腑銆傘€傘€?/p>








以上是关于linux鏃ュ父甯哥敤鍛戒护鏁寸悊的主要内容,如果未能解决你的问题,请参考以下文章

Linux甯哥敤鍛戒护

Linux甯哥敤鍛戒护

Linux甯哥敤鍛戒护

linux甯哥敤鍛戒护--宸ヤ綔璁板綍20201126

GitLab 甯哥敤鍛戒护

sql甯哥敤鍛戒护