{"id":184,"date":"2021-07-28T10:23:26","date_gmt":"2021-07-28T02:23:26","guid":{"rendered":"http:\/\/egonlin.com\/?p=184"},"modified":"2024-03-21T12:10:04","modified_gmt":"2024-03-21T04:10:04","slug":"%e7%ac%ac%e4%ba%8c%e8%8a%82%ef%bc%9a%e6%96%87%e4%bb%b6%e7%ae%a1%e7%90%86%e9%ab%98%e7%ba%a7","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=184","title":{"rendered":"\u7b2c\u4e8c\u8282\uff1a\u6587\u4ef6\u7ba1\u7406\u9ad8\u7ea7"},"content":{"rendered":"<h1>\u6587\u4ef6\u7ba1\u7406\u4e4b\uff08\u9ad8\u7ea7\uff09<\/h1>\n<h2>\u4e00 \u6587\u672c\u5904\u7406\u4e09\u5251\u5ba2\u547d\u4ee4\u521d\u63a2<\/h2>\n<p>\u4e09\u5251\u5ba2\u547d\u4ee4\u6211\u4eec\u5c06\u5728shell\u7f16\u7a0b\u91cc\u6df1\u5165\u8bb2\u89e3\uff0c\u6b64\u5904\u5148\u5b66\u4f1a\u6700\u57fa\u672c\u7684\u4f7f\u7528<\/p>\n<h3>1.1 sed<\/h3>\n<p>\u6d41\u5f0f\u7f16\u8f91\u5668\uff0c\u4e3b\u8981\u64c5\u957f\u5bf9\u6587\u4ef6\u7684\u7f16\u8f91\u64cd\u4f5c\uff0c\u6211\u4eec\u53ef\u4ee5\u4e8b\u5148\u5b9a\u5236\u597d\u7f16\u8f91\u6587\u4ef6\u7684\u6307\u4ee4\uff0c\u7136\u540e\u8ba9sed\u81ea\u52a8\u5b8c\u6210\u5bf9\u6587\u4ef6\u7684\u6574\u4f53\u7f16\u8f91<\/p>\n<pre><code class=\"language-python\"># \u7528\u6cd5\nsed \u9009\u9879 &#039;\u5b9a\u4f4d+\u547d\u4ee4&#039; \u6587\u4ef6\u8def\u5f84\n\n# \u9009\u9879\n-n \u53d6\u6d88\u9ed8\u8ba4\u8f93\u51fa\n-r \u652f\u6301\u6269\u5c55\u6b63\u5219\u5143\u5b57\u7b26(\u7531\u4e8e\u5c1a\u672a\u5b66\u4e60\u6b63\u5219\uff0c\u6240\u4ee5\u6b64\u5904\u6682\u4f5c\u4e86\u89e3\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06\u4f1a\u5728shell\u7f16\u7a0b\u7b2c\u4e5d\u7ae0\u7b2c\u4e00\u8282\u4ecb\u7ecd)\n-i \u7acb\u5373\u7f16\u8f91\u6587\u4ef6\n\n# \u5b9a\u4f4d\n\u884c\u5b9a\u4f4d\uff1a\n    1\u5b9a\u4f4d\u5230\u7b2c\u4e00\u884c\n    1,3\u4ee3\u8868\u4ece\u7b2c1\u884c\u5230\u7b2c3\u884c\n    \u4e0d\u5199\u5b9a\u4f4d\u4ee3\u8868\u5b9a\u4f4d\u6240\u6709\u884c\n\u6b63\u5219\u8868\u8fbe\u5f0f\u5b9a\u4f4d\uff1a\n    \/egon\/ \u5305\u542begon\u7684\u884c\n    \/^egon\/ \u4ee5egon\u5f00\u5934\u7684\u884c \n    \/egon$\/\u4ee5egon\u7ed3\u5c3e\u7684\u884c\n\u6570\u5b57+\u6b63\u5219\u8868\u8fbe\u5f0f\u5b9a\u4f4d\n    &quot;1,8p&quot;\u4ee3\u8868\u6253\u53701\u52308\u884c\uff0c\n    &quot;1,\/egon\/p&quot;\u5219\u4ee3\u8868\u53d6\u4ece\u7b2c1\u884c\u5230\u9996\u6b21\u5339\u914d\u5230\/egon\/\u7684\u884c\n\n# \u547d\u4ee4\nd\np\ns\/\/\/g\n\u547d\u4ee4\u53ef\u4ee5\u7528;\u53f7\u8fde\u63a5\u591a\u591a\u6761\uff0c\u59821d;3d;5d\u4ee3\u8868\u5220\u96641\uff0c3\uff0c5\u884c\n\n# =========================\u300b\u7528\u6cd5\u793a\u4f8b\uff1ap\u4e0ed\n[root@localhost ~]# sed &#039;&#039; a.txt \negon1111\n22222egon\n3333egon33333\n4444xxx44444\n5555xxx55555xxxx555xxx\n6666egon6666egon666egon\n[root@localhost ~]# sed -n &#039;&#039; a.txt \n[root@localhost ~]# \n[root@localhost ~]# sed -n &#039;1,\/xxx\/p&#039; a.txt \negon1111\n22222egon\n3333egon33333\n4444xxx44444\n[root@localhost ~]# sed &#039;1,\/xxx\/d&#039; a.txt \n5555xxx55555xxxx555xxx\n6666egon6666egon666egon\n[root@localhost ~]# sed &#039;1d;3d;5d&#039; a.txt \n22222egon\n4444xxx44444\n6666egon6666egon666egon\n\n# =========================\u300b\u7528\u6cd5\u793a\u4f8b: s\/\/\/g\n[root@localhost ~]# cat a.txt \negon1111\n22222egon\n3333egon33333\n4444xxx44444\n5555xxx55555xxxx555xxx\n6666egon6666egon666egon\n[root@localhost ~]# sed &#039;s\/egon\/BIGEGON\/g&#039; a.txt  # \u628a\u6240\u6709\u884c\u7684\u6240\u6709\u7684egon\u90fd\u6362\u6210BIGEGON\nBIGEGON1111\n22222BIGEGON\n3333BIGEGON33333\n4444xxx44444\n5555xxx55555xxxx555xxx\n6666BIGEGON6666BIGEGON666BIGEGON\n[root@localhost ~]# \n[root@localhost ~]# sed &#039;\/^egon\/s\/egon\/GAGAGA\/g&#039; a.txt  # \u4ee5egon\u5f00\u5934\u7684\u884c\u4e2d\u7684egon\u6362\u6210GAGAGA\nGAGAGA1111\n22222egon\n3333egon33333\n4444xxx44444\n5555xxx55555xxxx555xxx\n6666egon6666egon666egon\n[root@localhost ~]# sed &#039;6s\/egon\/BIGEGON\/&#039; a.txt  # \u53ea\u628a\u7b2c6\u884c\u7684egon\u6362\u6210BIGEGON\uff0c\u52a0\u4e0ag\u4ee3\u8868\uff1f\uff1f\uff1f\negon1111\n22222egon\n3333egon33333\n4444xxx44444\n5555xxx55555xxxx555xxx\n6666BIGEGON6666egon666egon\n[root@localhost ~]# \n[root@localhost ~]# sed &#039;1,3s\/egon\/BIGEGON\/g&#039; a.txt # \u628a1\u52303\u884c\u7684egon\u6362\u6210BIGEGON\nBIGEGON1111\n22222BIGEGON\n3333BIGEGON33333\n4444xxx44444\n5555xxx55555xxxx555xxx\n6666egon6666egon666egon\n\n[root@localhost ~]# cat a.txt | sed &#039;1,5d&#039;  # sed\u4e5f\u652f\u6301\u7ba1\u9053\n6666egon6666egon666egon\n# \u52a0\u4e0a-i\u9009\u9879\uff0c\u76f4\u63a5\u4fee\u6539\u6587\u4ef6\uff0c\u901a\u5e38\u4f1a\u5728\u8c03\u8bd5\u5b8c\u6bd5\u786e\u4fdd\u6ca1\u6709\u95ee\u9898\u540e\u518d\u52a0-i\u9009\u9879<\/code><\/pre>\n<h3>1.2 awk<\/h3>\n<p>awk\u4e3b\u8981\u7528\u4e8e\u5904\u7406\u6709\u683c\u5f0f\u7684\u6587\u672c\uff0c\u4f8b\u5982\/etc\/passwd\u8fd9\u79cd<\/p>\n<pre><code class=\"language-python\"># \u7528\u6cd5\nawk \u9009\u9879 &#039;pattern{action}&#039; \u6587\u4ef6\u8def\u5f84\n\n# \u9009\u9879\n-F \u6307\u5b9a\u884c\u5206\u9694\u7b26\n\n# \u5de5\u4f5c\u6d41\u7a0b\nawk -F: &#039;{print $1,$3}&#039; \/etc\/passwd\n\n1\u3001awk\u4f1a\u8bfb\u53d6\u6587\u4ef6\u7684\u4e00\u884c\u5185\u5bb9\u7136\u540e\u8d4b\u503c\u7ed9$0\n2\u3001\u7136\u540eawk\u4f1a\u4ee5-F\u6307\u5b9a\u7684\u5206\u9694\u7b26\u5c06\u8be5\u884c\u5207\u5206\u6210n\u6bb5\uff0c\u6700\u591a\u53ef\u4ee5\u8fbe\u5230100\u6bb5\uff0c\u7b2c\u4e00\u6bb5\u7ed9$1,\u7b2c\u4e8c\u6bb5\u7ed9$2,\u4f9d\u6b21\u6b21\u7c7b\u63a8\n3\u3001print\u8f93\u51fa\u8be5\u884c\u7684\u7b2c\u4e00\u6bb5\u548c\u7b2c\u4e09\u6bb5\uff0c\u9017\u53f7\u4ee3\u8868\u8f93\u51fa\u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u4e0e-F\u4fdd\u6301\u4e00\u81f4\n4\u3001\u91cd\u590d\u6b65\u9aa41,2,3\u76f4\u5230\u6587\u4ef6\u5185\u5bb9\u8bfb\u5b8c\n\n# \u5185\u7f6e\u53d8\u91cf\n$0 \u4e00\u6574\u884c\u5185\u5bb9\nNR \u8bb0\u5f55\u53f7\uff0c\u7b49\u540c\u4e8e\u884c\u53f7\nNF \u4ee5-F\u5206\u9694\u7b26\u5206\u9694\u7684\u6bb5\u6570\n\n# pattern\u53ef\u4ee5\u662f\n\/\u6b63\u5219\/\n    \/\u6b63\u5219\/       # \u8be5\u884c\u5185\u5bb9\u5339\u914d\u6210\u529f\u6b63\u5219\n    $1 ~ \/\u6b63\u5219\/  # \u7b2c\u4e00\u6bb5\u5185\u5bb9\u5339\u914d\u6210\u529f\u6b63\u5219\n    $1 !~ \/\u6b63\u5219\/  # \u7b2c\u4e00\u6bb5\u5185\u5bb9\u6ca1\u6709\u5339\u914d\u6210\u529f\u6b63\u5219\n\u6bd4\u8f83\u8fd0\u7b97\uff1a\n    NR &gt;= 3 &amp;&amp; NR &lt;=5  # 3\u52305\u884c\n    $1 == &quot;root&quot;      # \u7b2c\u4e00\u6bb5\u5185\u5bb9\u7b49\u4e8eroot\n\n# action\u53ef\u4ee5\u662f\nprint $1,$3\n\n# \u7528\u6cd5\u793a\u4f8b\n[root@localhost ~]# cat a.txt \nroot:x:0:0:root:\/root:\/bin\/bash\nbin:x:1:1:bin:\/bin:\/sbin\/nologin\ndaemon:x:2:2:daemon:\/sbin:\/sbin\/nologin\nadm:x:3:4:adm:\/var\/adm:\/sbin\/nologin\nlp:x:4:7:lp:\/var\/spool\/lpd:\/sbin\/nologin\n[root@localhost ~]# awk -F: &#039;\/^root\/{print $1,$3}&#039; a.txt \nroot 0\n[root@localhost ~]# awk -F: &#039;$1 ~ \/^d\/{print $1,$3}&#039; a.txt \ndaemon 2\n[root@localhost ~]# awk -F: &#039;$1 !~ \/^d\/{print $1,$3}&#039; a.txt \nroot 0\nbin 1\nadm 3\nlp 4\n[root@localhost ~]# awk -F: &#039;NR&gt;3{print $1}&#039; a.txt \nadm\nlp\n[root@localhost ~]# awk -F: &#039;$1 == &quot;lp&quot;{print $0}&#039; a.txt \nlp:x:4:7:lp:\/var\/spool\/lpd:\/sbin\/nologin\n[root@localhost ~]# \n\n[root@localhost ~]# cat a.txt | awk -F: &#039;{print $1}&#039; # awk\u4e5f\u652f\u6301\u7ba1\u9053\nroot\nbin\ndaemon\nadm\nlp\n[root@localhost ~]# <\/code><\/pre>\n<p>\u4e8b\u5b9e\u4e0aawk\u662f\u4e00\u95e8\u7f16\u7a0b\u8bed\u8a00\uff0c\u53ef\u4ee5\u72ec\u7acb\u5b8c\u6210\u5f88\u5f3a\u5927\u7684\u64cd\u4f5c\uff0c\u6211\u4eec\u5c06\u5728shell\u7f16\u7a0b\u4e2d\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n<h3>1.3 grep<\/h3>\n<p>grep\u64c5\u957f\u8fc7\u6ee4\u5185\u5bb9<\/p>\n<pre><code class=\"language-python\"># \u7528\u6cd5\ngrep \u9009\u9879 &#039;\u6b63\u5219&#039; \u6587\u4ef6\u8def\u5f84\n\n# \u9009\u9879\n-n, --line-number           \u5728\u8fc7\u6ee4\u51fa\u7684\u6bcf\u4e00\u884c\u524d\u9762\u52a0\u4e0a\u5b83\u5728\u6587\u4ef6\u4e2d\u7684\u76f8\u5bf9\u884c\u53f7\n-i, --ignore-case           \u5ffd\u7565\u5927\u5c0f\u5199\n--color                     \u989c\u8272\n-l, --files-with-matches    \u5982\u679c\u5339\u914d\u6210\u529f\uff0c\u5219\u53ea\u5c06\u6587\u4ef6\u540d\u6253\u5370\u51fa\u6765\uff0c\u5931\u8d25\u5219\u4e0d\u6253\u5370\n                            \u901a\u5e38-rl\u4e00\u8d77\u7528\uff0cgrep -rl &#039;root&#039; \/etc \n-R, -r, --recursive         \u9012\u5f52\n\n# \u793a\u4f8b\n[root@localhost ~]# grep &#039;^root&#039; \/etc\/passwd\nroot:x:0:0:root:\/root:\/bin\/bash\n\n[root@localhost ~]# grep -n &#039;bash$&#039; \/etc\/passwd\n1:root:x:0:0:root:\/root:\/bin\/bash\n44:egon:x:1000:1000:egon:\/home\/egon:\/bin\/bash\n\n[root@localhost ~]# grep -rl &#039;root&#039; \/etc    \n\n# grep\u4e5f\u652f\u6301\u7ba1\u9053\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u4e09\u5251\u5ba2\u547d\u4ee4\u90fd\u652f\u6301\u7ba1\u9053\n[root@localhost ~]# ps aux |grep ssh\nroot        968  0.0  0.2 112908  4312 ?        Ss   14:05   0:00 \/usr\/sbin\/sshd -D\nroot       1305  0.0  0.3 163604  6096 ?        Ss   14:05   0:00 sshd: root@pts\/0\nroot       1406  0.0  0.3 163600  6240 ?        Ss   14:05   0:00 sshd: root@pts\/1\nroot       2308  0.0  0.0 112724   984 pts\/1    R+   15:30   0:00 grep --color=auto ssh\n[root@localhost ~]# ps aux |grep [s]sh\nroot        968  0.0  0.2 112908  4312 ?        Ss   14:05   0:00 \/usr\/sbin\/sshd -D\nroot       1305  0.0  0.3 163604  6096 ?        Ss   14:05   0:00 sshd: root@pts\/0\nroot       1406  0.0  0.3 163600  6240 ?        Ss   14:05   0:00 sshd: root@pts\/1<\/code><\/pre>\n<h2>\u4e8c \u6587\u4ef6\u7ba1\u7406\u4e4b\uff1a\u6587\u4ef6\u67e5\u627e<\/h2>\n<p>\u4e00\u3001\u67e5\u770b\u547d\u4ee4\u6240\u5c5e\u6587\u4ef6<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# which ip\n\/usr\/sbin\/ip\n\n# ps: \u4e00\u4e9b\u547d\u4ee4\u7684\u8def\u5f84\u90fd\u88ab\u914d\u7f6e\u5230\u4e86\u73af\u5883\u53d8\u91cfPATH\u91cc\n    echo $PATH<\/code><\/pre>\n<p>\u4e8c\u3001\u67e5\u627e\u6587\u4ef6<\/p>\n<pre><code class=\"language-python\">find [options] [path...] [expression]<\/code><\/pre>\n<p>\u6309\u6587\u4ef6\u540d\uff1a<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# find \/etc -name &quot;ifcfg-eth0&quot;\n[root@localhost ~]# find \/etc -iname &quot;ifcfg-eth0&quot;     # -i\u5ffd\u7565\u5927\u5c0f\u5199\n[root@localhost ~]# find \/etc -iname &quot;ifcfg-eth*&quot;<\/code><\/pre>\n<p>\u6309\u6587\u4ef6\u5927\u5c0f\uff1a<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# find \/etc -size +3M                 # \u5927\u4e8e3M\n[root@localhost ~]# find \/etc -size 3M\n[root@localhost ~]# find \/etc -size -3M\n[root@localhost ~]# find \/etc -size +3M -ls             # -ls\u627e\u5230\u7684\u5904\u7406\u52a8\u4f5c<\/code><\/pre>\n<p>\u6307\u5b9a\u67e5\u627e\u7684\u76ee\u5f55\u6df1\u5ea6\uff1a<\/p>\n<pre><code class=\"language-python\">-maxdepth levels\n[root@localhost ~]# find \/ -maxdepth 5 -a  -name &quot;ifcfg-eth0&quot;  # -a\u5e76\u4e14\uff0c-o\u6216\u8005\uff0c\u4e0d\u52a0-a\uff0c\u9ed8\u8ba4\u5c31\u662f-a<\/code><\/pre>\n<p>\u6309\u65f6\u95f4\u627e(atime,mtime,ctime)\uff1a<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# find \/etc -mtime +3                 # \u4fee\u6539\u65f6\u95f4\u8d85\u8fc73\u5929\n[root@localhost ~]# find \/etc -mtime 3                  # \u4fee\u6539\u65f6\u95f4\u7b49\u4e8e3\u5929\n[root@localhost ~]# find \/etc -mtime -3                 # \u4fee\u6539\u65f6\u95f43\u5929\u4ee5\u5185<\/code><\/pre>\n<p>\u6309\u6587\u4ef6\u5c5e\u4e3b\u3001\u5c5e\u7ec4\u627e\uff1a<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# find \/home -user egon               # \u5c5e\u4e3b\u662fegon\u7684\u6587\u4ef6\n[root@localhost ~]# find \/home -group it                # \u5c5e\u7ec4\u662fit\u7ec4\u7684\u6587\u4ef6\n[root@localhost ~]# find \/home -user egon -group it\n[root@localhost ~]# find \/home -user egon -a -group it  # \u540c\u4e0a\u610f\u601d\u4e00\u6837\n[root@localhost ~]# find \/home -user egon -o -group it\n[root@localhost ~]# find \/home -nouser  # \u7528\u6237\u8fd8\u5b58\u5728\uff0c\u5728\/etc\/passwd\u4e2d\u5220\u9664\u4e86\u8bb0\u5f55\n[root@localhost ~]# find \/home -nogroup  # \u7528\u6237\u8fd8\u5b58\u5728\uff0c\u5728\/etc\/group\u4e2d\u5220\u9664\u4e86\u8bb0\u5f55\n[root@localhost ~]# find \/home -nouser -o -nogroup <\/code><\/pre>\n<p>\u6309\u6587\u4ef6\u7c7b\u578b\uff1a<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# find \/dev -type f                       # f\u666e\u901a\n[root@localhost ~]# find \/dev -type d                       # d\u76ee\u5f55\n[root@localhost ~]# find \/dev -type l                       # l\u94fe\u63a5\n[root@localhost ~]# find \/dev -type b                       # b\u5757\u8bbe\u5907\n[root@localhost ~]# find \/dev -type c                       # c\u5b57\u7b26\u8bbe\u5907\n[root@localhost ~]# find \/dev -type s                       # s\u5957\u63a5\u5b57\n[root@localhost ~]# find \/dev -type p                       # p\u7ba1\u9053\u6587\u4ef6<\/code><\/pre>\n<p>\u6839\u636einode\u53f7\u67e5\u627e\uff1a-inum n <\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# find \/ -inum 1811<\/code><\/pre>\n<p>\u6309\u6587\u4ef6\u6743\u9650\uff1a<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# find . -perm 644 -ls\n[root@localhost ~]# find . -perm -644 -ls\n[root@localhost ~]# find . -perm -600 -ls\n[root@localhost ~]# find \/sbin -perm -4000 -ls      # \u5305\u542bset uid\n[root@localhost ~]# find \/sbin -perm -2000 -ls      # \u5305\u542bset gid\n[root@localhost ~]# find \/sbin -perm -1000 -ls      # \u5305\u542bsticky<\/code><\/pre>\n<p>\u627e\u5230\u540e\u5904\u7406\u7684\u52a8\u4f5c\uff1a<\/p>\n<pre><code class=\"language-python\">-print\n-ls\n-delete\n-exec\n-ok\n[root@localhost ~]# find \/etc -name &quot;ifcfg*&quot; -print  # \u5fc5\u987b\u52a0\u5f15\u53f7\n[root@localhost ~]# find \/etc -name &quot;ifcfg*&quot; -ls\n[root@localhost ~]# find \/etc -name &quot;ifcfg*&quot; -exec cp -rvf {} \/tmp \\;  # \u975e\u4ea4\u4e92\n[root@localhost ~]# find \/etc -name &quot;ifcfg*&quot; -ok cp -rvf {} \/tmp \\;  # \u4ea4\u4e92\n\n[root@localhost ~]# find \/etc -name &quot;ifcfg*&quot; -exec rm -rf {} \\;\n[root@localhost ~]# find \/etc -name &quot;ifcfg*&quot; -delete  # \u540c\u4e0a<\/code><\/pre>\n<p>\u6269\u5c55\u77e5\u8bc6\uff1afind\u7ed3\u5408xargs<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# find . -name &quot;egon*.txt&quot; |xargs rm -rf\n\n[root@localhost ~]# find \/etc -name &quot;ifcfg-eth0&quot; |xargs -I {} cp -rf {} \/var\/tmp\n[root@localhost ~]# find \/test -name &quot;ifcfg-ens33&quot; |xargs -I {} mv {} \/ttt\n[root@localhost ~]# find \/ttt\/ -name &quot;ifcfg*&quot; |xargs -I {} chmod 666 {}<\/code><\/pre>\n<p>find\u4f5c\u4e1a\uff1a<\/p>\n<ol>\n<li>\u67e5\u627eifconfig\u547d\u4ee4\u6587\u4ef6\u7684\u4f4d\u7f6e\uff0c\u7528\u4e0d\u540c\u7684\u65b9\u5f0f\u5b9e\u73b0<\/li>\n<li>\u67e5\u627e\/etc\/\u4e2d\u7684\u6240\u6709\u5b50\u76ee\u5f55\uff08\u4ec5\u76ee\u5f55\uff09\u590d\u5236\u5230\/tmp\u4e0b<\/li>\n<li>\u67e5\u627e\/etc\u76ee\u5f55\u590d\u5236\u5230\/var\/tmp\/\uff0c<br \/>\n\u5c06\/var\/tmp\/etc\u4e2d\u7684\u6240\u6709\u76ee\u5f55\u8bbe\u7f6e\u6743\u9650777(\u4ec5\u76ee\u5f55)<br \/>\n\u5c06\/var\/tmp\/etc\u4e2d\u6240\u6709\u6587\u4ef6\u6743\u9650\u8bbe\u7f6e\u4e3a666<\/li>\n<\/ol>\n<h2>\u4e09 \u6587\u4ef6\u7ba1\u7406\u4e4b\uff1a\u4e0a\u4f20\u4e0e\u4e0b\u8f7d<\/h2>\n<p>\uff081\uff09\u4e0b\u8f7d<\/p>\n<p>wget\u547d\u4ee4<\/p>\n<pre><code class=\"language-python\">wget -O \u672c\u5730\u8def\u5f84 \u8fdc\u7a0b\u5305\u94fe\u63a5\u5730\u5740  # \u5c06\u8fdc\u7a0b\u5305\u4e0b\u8f7d\u5230\u672c\u5730\uff0c-O\u6307\u5b9a\u4e0b\u8f7d\u5230\u54ea\u91cc\uff0c\u53ef\u4ee5\u751f\u8def-O \u672c\u5730\u8def\u5f84\n\n# ps\uff1a\u5982\u679cwget\u4e0b\u8f7d\u63d0\u793a\u65e0\u6cd5\u5efa\u7acbSSL\u8fde\u63a5\uff0c\u5219\u52a0\u4e0a\u9009\u9879--no-check-certificate\nwget --no-check-certificate -O \u672c\u5730\u8def\u5f84 \u8fdc\u7a0b\u5305\u94fe\u63a5\u5730\u5740 <\/code><\/pre>\n<p>curl\u547d\u4ee4<\/p>\n<pre><code class=\"language-python\">#curl\u547d\u4ee4\u662f\u4e00\u4e2a\u5229\u7528URL\u89c4\u5219\u5728\u547d\u4ee4\u884c\u4e0b\u5de5\u4f5c\u7684\u6587\u4ef6\u4f20\u8f93\u5de5\u5177\u3002\u5b83\u652f\u6301\u6587\u4ef6\u7684\u4e0a\u4f20\u548c\u4e0b\u8f7d\uff0c\u6240\u4ee5\u662f\u7efc\u5408\u4f20\u8f93\u5de5\u5177\uff0c\u4f46\u6309\u4f20\u7edf\uff0c\u4e60\u60ef\u79f0curl\u4e3a\u4e0b\u8f7d\u5de5\u5177\u3002\u4f5c\u4e3a\u4e00\u6b3e\u5f3a\u529b\u5de5\u5177\uff0ccurl\u652f\u6301\u5305\u62ecHTTP\u3001HTTPS\u3001[ftp]\u7b49\u4f17\u591a\u534f\u8bae\uff0c\u8fd8\u652f\u6301POST\u3001cookies\u3001\u8ba4\u8bc1\u3001\u4ece\u6307\u5b9a\u504f\u79fb\u5904\u4e0b\u8f7d\u90e8\u5206\u6587\u4ef6\u3001\u7528\u6237\u4ee3\u7406\u5b57\u7b26\u4e32\u3001\u9650\u901f\u3001\u6587\u4ef6\u5927\u5c0f\u3001\u8fdb\u5ea6\u6761\u7b49\u7279\u5f81\u3002\u505a\u7f51\u9875\u5904\u7406\u6d41\u7a0b\u548c\u6570\u636e\u68c0\u7d22\u81ea\u52a8\u5316\uff0ccurl\u53ef\u4ee5\u795d\u4e00\u81c2\u4e4b\u529b\u3002\n\n[root@localhost ~]# curl -o 123.png https:\/\/www.xxx.com\/img\/hello.png\n\n# ps: \u5982\u679c\u9047\u5230\u4e0b\u8f7d\u63d0\u793a\u65e0\u6cd5\u7b80\u5386SSL\u94fe\u63a5\uff0c\u4f7f\u7528-k\u9009\u9879\u6216\u8005--insecure\ncurl -k -o 123.png https:\/\/www.xxx.com\/img\/hello.png\n\n# \u4e0b\u8f7d\u8fdc\u7a0b\u811a\u672c\u5e76\u76f4\u63a5\u5728\u672c\u5730\u6267\u884c\n# \u4f60\u53ef\u4ee5\u5728\u8fdc\u7a0b\u5728test.sh\u6240\u5728\u7684\u6587\u4ef6\u5939\u4e0b\u6267\u884cpython3 -m http.server 8899\u542f\u52a8\u4e00\u4e2a\u670d\u52a1\uff0cPython2\u5219\u7528python2 -m SimpleHTTPServer 8899\n# \u7136\u540e\u5728\u672c\u5730\u6267\u884c\uff08\u6ce8\u610f\u5173\u95ed\u9632\u706b\u5899\u4e0eselinux\uff09\ncurl -s http:\/\/192.168.71.206:8899\/test.sh | bash  # -s\u4ee3\u8868\u9759\u9ed8\u6a21\u5f0f\uff0c\u4f1a\u5c4f\u853d\u6389curl\u547d\u4ee4\u672c\u8eab\u7684\u8f93\u51fa<\/code><\/pre>\n<p>sz\u547d\u4ee4<\/p>\n<pre><code class=\"language-python\"># \u7cfb\u7edf\u9ed8\u8ba4\u6ca1\u6709\u8be5\u547d\u4ee4\uff0c\u9700\u8981\u4e0b\u8f7d:yum install lrzsz -y\n# \u5c06\u670d\u52a1\u5668\u4e0a\u9009\u5b9a\u7684\u6587\u4ef6\u4e0b\u8f7d\/\u53d1\u9001\u5230\u672c\u673a\uff0c\n[root@localhost ~]# sz bak.tar.gz<\/code><\/pre>\n<p>\uff082\uff09\u4e0a\u4f20<\/p>\n<p>rz\u547d\u4ee4<\/p>\n<pre><code class=\"language-python\"># \u7cfb\u7edf\u9ed8\u8ba4\u6ca1\u6709\u8be5\u547d\u4ee4\uff0c\u9700\u8981\u4e0b\u8f7d\uff1ayum install lrzsz -y\n# \u8fd0\u884c\u8be5\u547d\u4ee4\u4f1a\u5f39\u51fa\u4e00\u4e2a\u6587\u4ef6\u9009\u62e9\u7a97\u53e3\uff0c\u4ece\u672c\u5730\u9009\u62e9\u6587\u4ef6\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u3002\n[root@localhost opt]# rz  # \u5982\u679c\u6587\u4ef6\u5df2\u7ecf\u5b58\uff0c\u5219\u4e0a\u4f20\u5931\u8d25\uff0c\u53ef\u4ee5\u7528-E\u9009\u9879\u89e3\u51b3\n[root@localhost opt]# rz -E # -E\u5982\u679c\u76ee\u6807\u6587\u4ef6\u540d\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u91cd\u547d\u540d\u4f20\u5165\u6587\u4ef6\u3002\u65b0\u6587\u4ef6\u540d\u5c06\u6dfb\u52a0\u4e00\u4e2a\u70b9\u548c\u4e00\u4e2a\u6570\u5b57(0..999\uff09<\/code><\/pre>\n<h2>\u56db \u6587\u4ef6\u7ba1\u7406\u4e4b\uff1a\u8f93\u51fa\u4e0e\u91cd\u5b9a\u5411<\/h2>\n<p>\u8f93\u51fa\u5373\u628a\u76f8\u5173\u5bf9\u8c61\u901a\u8fc7\u8f93\u51fa\u8bbe\u5907\uff08\u663e\u793a\u5668\u7b49\uff09\u663e\u793a\u51fa\u6765\uff0c\u8f93\u51fa\u53c8\u5206\u6b63\u786e\u8f93\u51fa\u548c\u9519\u8bef\u8f93\u51fa<br \/>\n\u4e00\u822c\u60c5\u51b5\u4e0b\u6807\u51c6\u8f93\u51fa\u8bbe\u5907\u4e3a\u663e\u793a\u5668\uff0c\u6807\u51c6\u8f93\u5165\u8bbe\u5907\u4e3a\u952e\u76d8\u3002<\/p>\n<p>linux\u4e2d\u7528<\/p>\n<ul>\n<li>\n<p>0\u4ee3\u8868\u6807\u51c6\u8f93\u5165<\/p>\n<\/li>\n<li>\n<p>1\u4ee3\u8868\u6807\u51c6\u6b63\u786e\u8f93\u51fa<\/p>\n<\/li>\n<li>\n<p>2\u4ee3\u8868\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u3002<\/p>\n<\/li>\n<\/ul>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u91cd\u5b9a\u54111-1-1024x313.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u91cd\u5b9a\u54111-1-1024x313.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p><strong>\u8f93\u51fa\u91cd\u5b9a\u5411\uff1a<\/strong><\/p>\n<p>\u6b63\u5e38\u8f93\u51fa\u662f\u628a\u5185\u5bb9\u8f93\u51fa\u5230\u663e\u793a\u5668\u4e0a\uff0c\u800c\u8f93\u51fa\u91cd\u5b9a\u5411\u662f\u628a\u5185\u5bb9\u8f93\u51fa\u5230\u6587\u4ef6\u4e2d\uff0c&gt;\u4ee3\u8868\u8986\u76d6\uff0c&gt;&gt;\u4ee3\u8868\u8ffd\u52a0<\/p>\n<p>Ps\uff1a\u6807\u51c6\u8f93\u51fa\u76841\u53ef\u4ee5\u7701\u7565<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u91cd\u5b9a\u54112-1024x359.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u91cd\u5b9a\u54112-1024x359.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u4f8b\u5982\uff1aifconfig &gt; test.log \u5373\u628aifconfig\u6267\u884c\u663e\u793a\u7684\u6b63\u786e\u5185\u5bb9\u5199\u5165test.log.\u5f53\u524d\u9875\u9762\u4e0d\u518d\u663e\u793a\u6267\u884c\u7ed3\u679c\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u9519\u8bef\u8f93\u51fa\u91cd\u5b9a\u5411&gt;\u4e0e&gt;&gt;\u540e\u8fb9\u4e0d\u8981\u52a0\u7a7a\u683c<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u91cd\u5b9a\u54113-1024x406.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u91cd\u5b9a\u54113-1024x406.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u6ce8\u610f\uff1a<\/p>\n<ul>\n<li>\n<p>1\u3001\u4e0b\u8ff0\u4e24\u4e2a\u547d\u4ee4\u4f5c\u7528\u76f8\u540c<\/p>\n<pre><code class=\"language-python\">\u547d\u4ee4 >>file.log 2>&1 \n\u547d\u4ee4 &>>file.log<\/code><\/pre>\n<\/li>\n<li>\n<p>2\u3001\u6b63\u786e\u65e5\u5fd7\u548c\u9519\u8bef\u65e5\u5fd7\u5206\u5f00\u4fdd\u5b58<\/p>\n<pre><code class=\"language-python\">\u547d\u4ee4 >>file1.log 2>>file2.log <\/code><\/pre>\n<\/li>\n<li>\n<p>3\u3001\u7cfb\u7edf\u6709\u4e2a\u5e38\u89c1\u7528\u6cd5 ls &amp;&gt;\/dev\/null \u6b63\u786e\u8f93\u51fa\u6216\u9519\u8bef\u8f93\u51fa\u7ed3\u679c\u90fd\u4e0d\u8981\u3002\uff08null\u53ef\u4ee5\u7406\u89e3\u4e3a\u9ed1\u6d1e\u6216\u5783\u573e\u7ad9\uff09<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u8f93\u5165\u91cd\u5b9a\u5411<\/strong><\/p>\n<pre><code class=\"language-python\">#\u6ca1\u6709\u6539\u53d8\u8f93\u5165\u7684\u65b9\u5411\uff0c\u9ed8\u8ba4\u952e\u76d8\uff0c\u6b64\u65f6\u7b49\u5f85\u8f93\u5165\n[root@egon ~]# tr &#039;N&#039; &#039;n&#039;\nNo\nno\n\n[root@egon ~]# tr &#039;N&#039; &#039;n&#039; &lt; file.txt\n\n#\u6ca1\u6709\u6539\u53d8\u8f93\u5165\u7684\u65b9\u5411\uff0c\u9ed8\u8ba4\u952e\u76d8\uff0c\u6b64\u65f6\u7b49\u5f85\u8f93\u5165\n[root@egon ~]# grep &#039;root&#039;\noldboy\nroot\nroot\n\n[root@egon ~]# grep &#039;root&#039; &lt; \/etc\/passwd\nroot:x:0:0:root:\/root:\/bin\/bash\n\n# \u8bfb\u5199\u5757\u8bbe\u5907\n[root@egon ~]# dd if=\/dev\/zero of=\/file1.txt bs=1M count=20\n[root@egon ~]# dd &lt;\/dev\/zero &gt;\/file2.txt bs=1M count=20\n\n# mysql\u5982\u4f55\u6062\u590d\u5907\u4efd\uff0c\u4e86\u89e3\u5373\u53ef\uff0c\u4e0d\u7528\u5173\u6ce8\u3002\n[root@qls ~]# mysql -uroot -p123 &lt; bbs.sql<\/code><\/pre>\n<h2>\u4e94 \u6587\u4ef6\u7ba1\u7406\u4e4b\uff1a\u5b57\u7b26\u5904\u7406\u547d\u4ee4<\/h2>\n<h4>5.1 sort\u547d\u4ee4<\/h4>\n<p>\u7528\u4e8e\u5c06\u6587\u4ef6\u5185\u5bb9\u52a0\u4ee5\u6392\u5e8f<\/p>\n<ul>\n<li>-n    # \u4f9d\u7167\u6570\u503c\u7684\u5927\u5c0f\u6392\u5e8f<\/li>\n<li>-r     # \u4ee5\u76f8\u53cd\u7684\u987a\u5e8f\u6765\u6392\u5e8f<\/li>\n<li>-k     # \u4ee5\u67d0\u5217\u8fdb\u884c\u6392\u5e8f<\/li>\n<li>-t      # \u6307\u5b9a\u5206\u5272\u7b26\uff0c\u9ed8\u8ba4\u662f\u4ee5\u7a7a\u683c\u4e3a\u5206\u9694\u7b26<\/li>\n<\/ul>\n<p>\u51c6\u5907\u6587\u4ef6\uff0c\u5199\u5165\u4e00\u6bb5\u65e0\u5e8f\u7684\u5185\u5bb9<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# cat &gt;&gt; file.txt &lt;&lt;EOF\nb:3\nc:2\na:4\ne:5\nd:1\nf:11\nEOF<\/code><\/pre>\n<p>\u4f8b1<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# sort file.txt \na:4\nb:3\nc:2\nd:1\ne:5\nf:11<\/code><\/pre>\n<p>\u4f8b2<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# sort -t &quot;:&quot; -n -k2 file.txt \nd:1\nc:2\nb:3\na:4\ne:5\nf:11<\/code><\/pre>\n<p>\u4f8b3<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# sort -t &quot;:&quot; -n -r -k2 file.txt \nf:11\ne:5\na:4\nb:3\nc:2\nd:1<\/code><\/pre>\n<h4>5.2 uniq \u547d\u4ee4<\/h4>\n<p>\u7528\u4e8e\u68c0\u67e5\u53ca\u5220\u9664\u6587\u672c\u6587\u4ef6\u4e2d\u91cd\u590d\u51fa\u73b0\u7684\u884c\u5217\uff0c\u4e00\u822c\u4e0e sort \u547d\u4ee4\u7ed3\u5408\u4f7f\u7528<\/p>\n<ul>\n<li>-c        # \u5728\u6bcf\u5217\u65c1\u8fb9\u663e\u793a\u8be5\u884c\u91cd\u590d\u51fa\u73b0\u7684\u6b21\u6570\u3002<\/li>\n<li>-d        # \u4ec5\u663e\u793a\u91cd\u590d\u51fa\u73b0\u7684\u884c\u5217\u3002<\/li>\n<li>-u        # \u4ec5\u663e\u793a\u51fa\u4e00\u6b21\u7684\u884c\u5217\u3002<\/li>\n<\/ul>\n<p>\u51c6\u5907\u6587\u4ef6\uff0c\u5199\u5165\u4e00\u6bb5\u65e0\u5e8f\u7684\u5185\u5bb9<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# cat &gt; file.txt &lt;&lt;EOF\nhello\n123\nhello\n123\nfunc\nEOF<\/code><\/pre>\n<p>\u4f8b1<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# sort file.txt \n123\n123\nfunc\nhello\nhello<\/code><\/pre>\n<p>\u4f8b2<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# sort file.txt | uniq\n123\nfunc\nhello<\/code><\/pre>\n<p>\u4f8b3<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# sort file.txt | uniq -c\n      2 123\n      1 func\n      2 hello<\/code><\/pre>\n<p>\u4f8b4<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# sort file.txt | uniq -d  \n123\nhello<\/code><\/pre>\n<h4>5.3 cut \u547d\u4ee4<\/h4>\n<p>cut\u547d\u4ee4\u7528\u6765\u663e\u793a\u884c\u4e2d\u7684\u6307\u5b9a\u90e8\u5206\uff0c\u5220\u9664\u6587\u4ef6\u4e2d\u6307\u5b9a\u5b57\u6bb5<\/p>\n<ul>\n<li>-d  # \u6307\u5b9a\u5b57\u6bb5\u7684\u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u7684\u5b57\u6bb5\u5206\u9694\u7b26\u4e3a&quot;TAB&quot;\uff1b<\/li>\n<li>-f  # \u663e\u793a\u6307\u5b9a\u5b57\u6bb5\u7684\u5185\u5bb9\uff1b<\/li>\n<\/ul>\n<pre><code class=\"language-python\">[root@localhost ~]# head -1 \/etc\/passwd \nroot:x:0:0:root:\/root:\/bin\/bash\n[root@localhost ~]# head -1 \/etc\/passwd | cut -d &quot;:&quot; -f1,3,4,6\nroot:0:0:\/root<\/code><\/pre>\n<p>\u7ec3\u4e60\uff1a<\/p>\n<pre><code># \u7b5b\u9009\u51fa\u5f53\u5929\u8bbf\u95eeip\u6392\u5728\u524d\u5341\u7684ip\u5730\u5740\ncat access.log | grep `LANG=&quot;en_US.UTF-8&quot; &amp;&amp; date +&quot;%d\/%b\/%Y&quot;`|awk &#039;{print $1}&#039;  |sort |uniq -c |sort -rn|awk &#039;{print $1&quot;:&quot;$2}&#039; | head -10\n\n# \u7b5b\u9009\u51fa\u56fa\u5b9a\u67d0\u4e00\u5929\u7684\u3001\u8bbf\u95eeip\u6392\u5728\u524d\u5341\u7684ip\u5730\u5740\ncat access.log | grep &quot;16\/Mar\/2024&quot; |awk &#039;{print $1}&#039;  |sort |uniq -c |sort -rn|awk &#039;{print $1&quot;:&quot;$2}&#039; | head -10\n\n# \u67e5\u8be2\u8bbf\u95ee\u6700\u9891\u7e41\u7684URL\nawk &#039;{print $7}&#039; access.log|sort | uniq -c |sort -n -k 1 -r|more\n\n# \u67e5\u8be2\u8bbf\u95ee\u6700\u9891\u7e41\u7684IP\nawk &#039;{print $1}&#039; access.log|sort | uniq -c |sort -n -k 1 -r|more\n\n# \u6839\u636e\u65f6\u95f4\u6bb5\u7edf\u8ba1\u67e5\u770b\u65e5\u5fd7\ncat  access.log| sed -n &#039;\/14\\\/Mar\\\/2015:21\/,\/14\\\/Mar\\\/2015:22\/p&#039;|more\n\naccess.log\u7ec3\u4e60\u6587\u4ef6\u4e0b\u8f7d\n\u94fe\u63a5\uff1ahttps:\/\/pan.baidu.com\/s\/1WiDO3vqGNiLhHv4vj29fUA \n\u63d0\u53d6\u7801\uff1aEgon <\/code><\/pre>\n<h4>5.4 tr\u547d\u4ee4<\/h4>\n<p>\u66ff\u6362\u6216\u5220\u9664\u547d\u4ee4<\/p>\n<ul>\n<li>-d    # \u5220\u9664\u5b57\u7b26<\/li>\n<\/ul>\n<p>\u4f8b1<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# head -1 \/etc\/passwd |tr &quot;root&quot; &quot;ROOT&quot;\nROOT:x:0:0:ROOT:\/ROOT:\/bin\/bash\n[root@localhost ~]# \n[root@localhost ~]# head -1 \/etc\/passwd |tr -d &quot;root&quot;\n:x:0:0::\/:\/bin\/bash<\/code><\/pre>\n<p>\u4f8b2<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# echo &quot;hello egon qq:378533872&quot; &gt; a.txt\n[root@localhost ~]# tr &quot;egon&quot; &quot;EGON&quot; &lt; a.txt \nhEllO EGON qq:378533872<\/code><\/pre>\n<h4>5.5 wc\u547d\u4ee4<\/h4>\n<p>\u7edf\u8ba1\uff0c\u8ba1\u7b97\u6570\u5b57<\/p>\n<ul>\n<li>-c        # \u7edf\u8ba1\u6587\u4ef6\u7684Bytes\u6570\uff1b<\/li>\n<li>-l        # \u7edf\u8ba1\u6587\u4ef6\u7684\u884c\u6570\uff1b<\/li>\n<li>-w      # \u7edf\u8ba1\u6587\u4ef6\u4e2d\u5355\u8bcd\u7684\u4e2a\u6570\uff0c\u9ed8\u8ba4\u4ee5\u7a7a\u767d\u5b57\u7b26\u505a\u4e3a\u5206\u9694\u7b26<\/li>\n<\/ul>\n<p>\u4f8b1<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# ll file.txt \n-rw-r--r--. 1 root root 25 8\u6708  12 20:09 file.txt\n[root@localhost ~]# wc -c file.txt \n25 file.txt<\/code><\/pre>\n<p>\u4f8b2<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# cat file.txt \nhello\n123\nhello\n123\nfunc\n[root@localhost ~]# wc -l file.txt \n5 file.txt\n[root@localhost ~]# grep &quot;hello&quot; file.txt |wc -l\n2<\/code><\/pre>\n<p>\u4f8b3<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# cat file.txt \nhello\n123\nhello\n123\nfunc\n[root@localhost ~]# wc -w file.txt \n5 file.txt<\/code><\/pre>\n<h2>\u516d \u6587\u4ef6\u7ba1\u7406\u4e4b\uff1a\u6253\u5305\u538b\u7f29\/\u5927\u6587\u4ef6\u5207\u5206<\/h2>\n<p><strong>1. \u4ec0\u4e48\u662f\u6253\u5305\u538b\u7f29<\/strong><\/p>\n<p>\u200b   \u6253\u5305\u6307\u7684\u662f\u5c06\u591a\u4e2a\u6587\u4ef6\u548c\u76ee\u5f55\u5408\u5e76\u4e3a\u4e00\u4e2a\u7279\u6b8a\u6587\u4ef6<\/p>\n<p>\u200b   \u7136\u540e\u5c06\u8be5\u7279\u6b8a\u6587\u4ef6\u8fdb\u884c\u538b\u7f29<\/p>\n<p>\u200b   \u6700\u7ec8\u5f97\u5230\u4e00\u4e2a\u538b\u7f29\u5305<\/p>\n<p><strong>2. \u4e3a\u4ec0\u4e48\u4f7f\u7528\u538b\u7f29\u5305<\/strong><br \/>\n1.\u51cf\u5c11\u5360\u7528\u7684\u4f53\u79ef<\/p>\n<p>\u200b   2.\u52a0\u5feb\u7f51\u7edc\u7684\u4f20\u8f93<\/p>\n<p><strong>3. Windows\u7684\u538b\u7f29\u548cLinux\u7684\u6709\u4ec0\u4e48\u4e0d\u540c<\/strong><br \/>\nwindows:     zip rar(linux\u4e0d\u652f\u6301)<\/p>\n<p>\u200b   linux:         zip tar.gz tar.bz2 .gz<\/p>\n<p>\u200b   \u5982\u679c\u5e0c\u671bwindows\u7684\u8f6f\u4ef6\u80fd\u88ablinux\u89e3\u538b,\u6216\u8005linux\u7684\u8f6f\u4ef6\u5305\u88abwindows\u80fd\u8bc6\u522b,\u9009\u62e9zip.<\/p>\n<p>\u200b   PS: \u538b\u7f29\u5305\u7684\u540e\u7f00\u4e0d\u91cd\u8981,\u4f46\u4e00\u5b9a\u8981\u643a\u5e26.<\/p>\n<p><strong>4. Linux\u4e0b\u5e38\u89c1\u7684\u538b\u7f29\u5305\u7c7b\u578b<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u683c\u5f0f<\/th>\n<th>\u538b\u7f29\u5de5\u5177<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>.zip<\/strong><\/td>\n<td><strong>zip\u538b\u7f29\u5de5\u5177<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>.gz<\/strong><\/td>\n<td><strong>gzip\u538b\u7f29\u5de5\u5177\uff0c\u53ea\u80fd\u538b\u7f29\u6587\u4ef6\uff0c\u4f1a\u5220\u9664\u6e90\u6587\u4ef6\uff08\u901a\u5e38\u914d\u5408tar\u4f7f\u7528\uff09<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>.bz2<\/strong><\/td>\n<td><strong>bzip2\u538b\u7f29\u5de5\u5177\uff0c\u53ea\u80fd\u538b\u7f29\u6587\u4ef6\uff0c\u4f1a\u5220\u9664\u6e90\u6587\u4ef6\uff08\u901a\u5e38\u914d\u5408tar\u4f7f\u7528\uff09<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>.tar.gz<\/strong><\/td>\n<td><strong>\u5148\u4f7f\u7528tar\u547d\u4ee4\u5f52\u6863\u6253\u5305\uff0c\u7136\u540e\u4f7f\u7528gzip\u538b\u7f29<\/strong><\/td>\n<\/tr>\n<tr>\n<td><strong>.tar.bz2<\/strong><\/td>\n<td><strong>\u5148\u4f7f\u7528tar\u547d\u4ee4\u5f52\u6863\u6253\u5305\uff0c\u7136\u540e\u4f7f\u7528bzip\u538b\u7f29<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>ps\uff1awindows\u4e0b\u652f\u6301.rar\uff0clinux\u4e0d\u652f\u6301.rar<\/p>\n<p><strong>6\u3001\u6253\u5305\u538b\u7f29\u65b9\u6cd5<\/strong><\/p>\n<p>\u65b9\u6cd5\u4e00\uff1a<\/p>\n<pre><code class=\"language-python\"># 1\u3001\u6253\u5305\n[root@localhost test]# tar cvf etc_bak.tar \/etc\/  # c\u521b\u5efa v\u8be6\u7ec6 f\u6253\u5305\u540e\u6587\u4ef6\u8def\u5f84\nps: \n    \u6253\u5305\u7684\u76ee\u6807\u8def\u5f84\u5982\u679c\u662f\u7edd\u5bf9\u8def\u5f84\uff0c\u4f1a\u63d0\u793a\uff1atar: \u4ece\u6210\u5458\u540d\u4e2d\u5220\u9664\u5f00\u5934\u7684\u201c\/\u201d\uff0c\u4e0d\u5f71\u54cd\u6253\u5305\uff0c\n    \u6dfb\u52a0-P\u9009\u9879\u4fbf\u4e0d\u518d\u63d0\u793a\uff1atar cvPf ...\n\n    \u53ef\u4ee5cd \u5230 \/etc\u4e0b\u7136\u540etar cvf etc_bak.tar *\u6253\u5305\uff0c\u8fd9\u6837\u53bb\u6389\u4e86\u4e00\u5c42\u6587\u4ef6\u5939\n\n# 2\u3001\u538b\u7f29\n[root@localhost test]# gzip etc_bak.tar   # \u6587\u4ef6\u4f53\u79ef\u53d8\u5c0f\uff0c\u5e76\u4e14\u52a0\u4e0a\u540e\u7f00.gz\nps:\n    gzip -&gt; gunzip\n    bzip2-&gt; bunzip2\n\n#3\u3001\u4e0a\u8ff0\u4e24\u6b65\u53ef\u4ee5\u5408\u4e8c\u4e3a\u4e00\n[root@localhost test]# tar czvf etc1_bak.tar.gz \/etc\/  # \u9009\u9879z\u4ee3\u8868gzip\u538b\u7f29\u7b97\u6cd5\n\n[root@localhost test]# tar cjvf etc1_bak.tar.bz2 \/etc\/  # \u9009\u9879j\u4ee3\u8868bzip2\u538b\u7f29\u7b97\u6cd5<\/code><\/pre>\n<p>\u65b9\u6cd5\u4e8c\uff1a<\/p>\n<pre><code class=\"language-python\">#zip\u538b\u7f29\n\u9009\u9879\uff1a\n\n    -r      #\u9012\u5f52\u538b\u7f29  \u538b\u7f29\u76ee\u5f55 \n\n    -q      #\u9759\u9ed8\u8f93\u51fa \n\n# \u793a\u4f8b1\u3001\n[root@localhost ~]# zip \/test\/bak.zip a.txt b.txt c.txt  # zip\u540e\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u538b\u7f29\u5305\u8def\u5f84\uff0c\u5176\u4f59\u4e3a\u88ab\u538b\u7f29\u7684\u6587\u4ef6\n  adding: a.txt (stored 0%)\n  adding: b.txt (stored 0%)\n  adding: c.txt (stored 0%)\n\n[root@localhost ~]# ls \/test\/\nbak.zip\n\n# \u793a\u4f8b1\u3001\n[root@localhost ~]# zip  -rq  etc.zip  \/etc  # \u52a0\u4e0a-q\u540e\u538b\u7f29\u8fc7\u7a0b\u4e0d\u518d\u63d0\u793a<\/code><\/pre>\n<p><strong>7\u3001\u89e3\u538b\u7f29<\/strong><\/p>\n<pre><code class=\"language-python\">#1\u3001\u9488\u5bf9xxx.tar.gz \u6216\u8005 xxx.tar.bz2\uff0c\u7edf\u4e00\u4f7f\u7528\n[root@localhost test]# tar xvf \u538b\u7f29\u5305 -C \u89e3\u538b\u5230\u7684\u76ee\u5f55  # \u65e0\u9700\u6307\u5b9a\u89e3\u538b\u7b97\u6cd5\uff0ctar\u4f1a\u81ea\u52a8\u5224\u65ad\n\n#2\u3001\u9488\u5bf9xxx.zip\uff0c\u7528unzip\n\u9009\u9879\uff1a\n\n    -l      #\u663e\u793a\u538b\u7f29\u5305\u7684\u5217\u8868\u4fe1\u606f\n\n    -q      #\u9759\u9ed8\u8f93\u51fa \n\n    -d      #\u89e3\u538b\u5230\u6307\u5b9a\u7684\u76ee\u5f55  \n[root@localhost test]# unzip -q xxx.zip -d \/opt<\/code><\/pre>\n<p><strong>8 \u62d3\u5c55<\/strong><\/p>\n<p>\u6253\u5305\u538b\u7f29\u901a\u5e38\u7528\u4e8e\u5907\u4efd\u6587\u4ef6\uff0c\u6587\u4ef6\u7684\u540d\u5b57\u5fc5\u987b\u89c1\u540d\u77e5\u610f\u4e14\u5e94\u8be5\u5e26\u4e0a\u65f6\u95f4\u3001\u4e3b\u673a\u540d\u4e4b\u7c7b<\/p>\n<p>\u65f6\u95f4\u547d\u4ee4date<\/p>\n<pre><code class=\"language-python\">#\u9009\u9879\n\n-d         #\u6839\u636e\u4f60\u7684\u63cf\u8ff0\u663e\u793a\u65e5\u671f\n\n-s     #\u4fee\u6539\u65e5\u671f\n\n%H         #\u5c0f\u65f6\uff0c24\u5c0f\u65f6\u5236\uff0800~23\uff09\n\n%M         #\u5206\u949f\uff0800~59\uff09\n\n%s         #\u4ece1970\u5e741\u67081\u65e500:00:00\u5230\u76ee\u524d\u7ecf\u5386\u7684\u79d2\u6570\n\n%S         #\u663e\u793a\u79d2\uff0800~59\uff09\n\n%T         #\u663e\u793a\u65f6\u95f4\uff0c24\u5c0f\u65f6\u5236\uff08hh:mm:ss\uff09\n\n%d         #\u4e00\u4e2a\u6708\u7684\u7b2c\u51e0\u5929\uff0801~31\uff09\n\n%j         #\u4e00\u5e74\u7684\u7b2c\u51e0\u5929\uff08001~366\uff09\n\n%m         #\u6708\u4efd\uff0801~12\uff09\n\n%w         #\u4e00\u4e2a\u661f\u671f\u7684\u7b2c\u51e0\u5929\uff080\u4ee3\u8868\u661f\u671f\u5929\uff09\n\n%W         #\u4e00\u5e74\u7684\u7b2c\u51e0\u4e2a\u661f\u671f\uff0800~53\uff0c\u661f\u671f\u4e00\u4e3a\u7b2c\u4e00\u5929\uff09\n\n%y         #\u5e74\u7684\u6700\u540e\u4e24\u4e2a\u6570\u5b57\uff081999\u5219\u662f99\uff09\n\n%Y         #\u5e74\uff0c\u5b9e\u9645\n\n%F         #\u663e\u793a\u65e5\u671f\uff08%Y-%m-%d\uff09<\/code><\/pre>\n<p>\u793a\u4f8b<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# date\n2020\u5e74 08\u6708 12\u65e5 \u661f\u671f\u4e09 20:55:48 CST\n[root@localhost ~]# date +%F\n2020-08-12\n[root@localhost ~]# date +%Y-%m-%d\n2020-08-12\n[root@localhost ~]# \n[root@localhost ~]# date +%y-%m-%d\n20-08-12\n[root@localhost ~]# date +%T\n00:01:03\n[root@localhost ~]# date +%H:%M:%S\n00:01:11\n[root@localhost ~]# \n[root@localhost ~]# date +%w\n3\n[root@localhost ~]# date +%s\n1597236988\n[root@localhost ~]# date +%d\n12\n[root@localhost ~]# date +%W\n32\n[root@localhost ~]# date +%j\n225\n[root@localhost ~]# date -d &quot;-1 day&quot; +%F\n2020-08-11\n[root@localhost ~]# date -d &quot;1 day&quot; +%F\n2020-08-13\n[root@localhost ~]# date -d &quot;+1 day&quot; +%F\n2020-08-13\n[root@localhost ~]# date -d &quot;3 years&quot; +%F\n2023-08-12\n[root@localhost ~]# date -d &quot;+3 years&quot; +%F\n2023-08-12\n[root@localhost ~]# date -d &quot;+3 hours&quot; +%F_%H:%M:%S\n2020-08-12_23:58:06\n\n[root@localhost ~]# date -s 20201111\n2020\u5e74 11\u6708 11\u65e5 \u661f\u671f\u4e09 00:00:00 CST\n[root@localhost ~]# date -s 11:11:11\n2020\u5e74 11\u6708 11\u65e5 \u661f\u671f\u4e09 11:11:11 CST\n[root@localhost ~]# date -s &quot;20201111 11:11:11&quot;\n2020\u5e74 11\u6708 11\u65e5 \u661f\u671f\u4e09 11:11:11 CST\n\n[root@localhost ~]# date +%F\n2020-11-11\n[root@localhost ~]# date +%T\n11:11:29<\/code><\/pre>\n<p>\u518d\u770b\u5907\u4efd<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# tar czvf `date +%F`_bak.tar.gz \/etc\n[root@localhost ~]# tar czvf `date +%F_%H_%M_%S`_bak.tar.gz \/etc  # \u5982\u679c\u5e26\u6709\u65f6\u5206\u79d2\uff0c\u4e0d\u8981\u7528\u5192\u53f7\u5206\u9694\uff0c\u56e0\u4e3a\u6587\u4ef6\u540d\u7684\u547d\u540d\u91cc\u4e0d\u80fd\u5e26\u6709\u5192\u53f7<\/code><\/pre>\n<p><strong>9 \u5927\u6587\u4ef6\u5207\u5206<\/strong><\/p>\n<pre><code class=\"language-bash\"># \u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u4e00\u4e9b\u6587\u4ef6\u6bd4\u8f83\u5927\uff0c\u52a8\u5219\u51e0\u4e2aG\uff0c\u6709\u7684\u5b89\u88c5\u5305\u548c\u955c\u50cf\u53ef\u8fbe\u5230\u5341\u51e0G\uff0c\u4f46\u662f\u6709\u4e9b\u5e73\u53f0\u663e\u793a\u4f20\u8f93\u6587 \u4ef6\u5927\u5c0f\uff0c\u6240\u4ee5\u4e00\u4e9b\u6bd4\u8f83\u5927\u7684\u6587\u4ef6\u4f1a\u88ab\u5207\u5272\u4e0a\u4f20\u518d\u5408\u5e76\u3002\n# \u8fd9\u91cc\u4ecb\u7ecd\u4e86\u4e2a\u6bd4\u8f83\u5e38\u7528\u7b80\u5355\u7684\u5207\u5272\u65b9\u5f0fsplit\nlinhaifeng01@appledeMacBook-Pro test % split -b 1024m vgpu-0.3.6.tgz\nlinhaifeng01@appledeMacBook-Pro test % \nlinhaifeng01@appledeMacBook-Pro test % ls\nvgpu-0.3.6.tgz  xaa     xab     xac\nlinhaifeng01@appledeMacBook-Pro test % ls -lh\ntotal 16206432\n-rw-r--r--  1 linhaifeng01  staff   2.6G  8  7 13:03 b.tar\n-rw-r--r--@ 1 linhaifeng01  staff   2.6G  8  5 16:22 vgpu-0.3.6.tgz\n-rw-r--r--  1 linhaifeng01  staff   1.0G  8  7 13:03 xaa\n-rw-r--r--  1 linhaifeng01  staff   1.0G  8  7 13:03 xab\n-rw-r--r--  1 linhaifeng01  staff   582M  8  7 13:03 xac\nlinhaifeng01@appledeMacBook-Pro test % \nlinhaifeng01@appledeMacBook-Pro test % \n\n# \u91cd\u65b0\u5408\u5e76\u6bd4\u5bf9md5\u503c\u662f\u4e00\u81f4\u7684\nlinhaifeng01@appledeMacBook-Pro test % md5 vgpu-0.3.6.tgz \nMD5 (vgpu-0.3.6.tgz) = 94583a6e02508d142594701234a080ff\nlinhaifeng01@appledeMacBook-Pro test % \nlinhaifeng01@appledeMacBook-Pro test % \nlinhaifeng01@appledeMacBook-Pro test % \nlinhaifeng01@appledeMacBook-Pro test % \nlinhaifeng01@appledeMacBook-Pro test % cat x* &gt; b.tar\nlinhaifeng01@appledeMacBook-Pro test % md5 b.tar \nMD5 (b.tar) = 94583a6e02508d142594701234a080ff\n<\/code><\/pre>\n<h2>\u4e03 \u6587\u4ef6\u7cfb\u7edf<\/h2>\n<h3>7.1 \u6587\u4ef6\u7cfb\u7edf\u4ecb\u7ecd<\/h3>\n<p>\u200b   \u6587\u4ef6\u7cfb\u7edffilesystem\u662f\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u4e2d\u8d1f\u8d23\u7ec4\u7ec7\u7ba1\u7406\u78c1\u76d8\u7684\u7a0b\u5e8f\u3002<\/p>\n<p>\u200b   \u5728\u4f20\u7edf\u7684\u78c1\u76d8\u4e0e\u6863\u6848\u7cfb\u7edf(\u53c8\u79f0\u4e3a\u6587\u4ef6\u7cfb\u7edffilesystem)\u7684\u5e94\u7528\u4e2d\uff0c\u4e00\u4e2a\u78c1\u76d8\u5206\u5272\u69fd\/\u5206\u533a\u53ea\u80fd\u88ab\u683c\u5f0f\u5316\u6210\u4e3a\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u8bf4\u4e00\u4e2afilesystem\u5c31\u662f\u4e00\u4e2apartition\u5206\u533a\u3002\u4f46\u662f\u7531\u4e8e\u65b0\u6280\u672f\u7684\u5229\u7528\uff0c\u4f8b\u5982\u6211\u4eec\u5e38\u542c\u5230\u7684LVM\u4e0e\u8f6f\u4f53\u78c1\u76d8\u9635\u5217(software raid\uff0c\u53c8\u79f0\u8f6fraid)\uff0c\u8fd9\u4e9b\u6280\u672f\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5206\u533a\u683c\u5f0f\u5316\u4e3a\u591a\u4e2a\u6587\u4ef6\u7cfb\u7edf(\u4f8b\u5982LVM)\uff0c\u4e5f\u80fd\u591f\u5c06\u591a\u4e2a\u5206\u533a\u5408\u6210\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf(LVM, RAID)\uff01\u6240\u4ee5\u8bf4\uff0c\u76ee\u524d\u6211\u4eec\u5728\u683c\u5f0f\u5316\u65f6\u5df2\u7ecf\u4e0d\u518d\u8bf4\u6210\u9488\u5bf9\u5206\u533a\u6765\u683c\u5f0f\u5316\u4e86\uff0c\u901a\u5e38\u6211\u4eec\u53ef\u4ee5\u79f0\u547c<strong>\u4e00\u4e2a\u53ef\u88ab\u6302\u8f7d\u7684\u8d44\u6599\u4e3a\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u800c\u4e0d\u662f\u4e00\u4e2a\u5206\u533a\uff01<\/strong>\u3002<\/p>\n<p>\u200b   linux\u5e38\u89c1\u6587\u4ef6\u7cfb\u7edf\u6709xfs\u3001ext4 \u548c btrfs \u6587\u4ef6\u7cfb\u7edf\uff0c\u5b83\u4eec\u90fd\u662f<a href=\"http:\/\/en.wikipedia.org\/wiki\/Journaling_file_system\">\u65e5\u5fd7\u6587\u4ef6\u7cfb\u7edf<\/a>\uff08\u5176\u7279\u70b9\u662f\u6587\u4ef6\u7cfb\u7edf\u5c06\u6ca1\u63d0\u4ea4\u7684\u6570\u636e\u53d8\u5316\u4fdd\u5b58\u5230\u65e5\u5fd7\u6587\u4ef6\uff0c\u4ee5\u4fbf\u5728\u7cfb\u7edf\u5d29\u6e83\u6216\u8005\u6389\u7535\u65f6\u6062\u590d\u6570\u636e\uff09\uff0c\u4e09\u8005\u5404\u6709\u4f18\u52bf\u548c\u52a3\u52bf\uff1a<\/p>\n<ul>\n<li>btrfs \uff08B-tree \u6587\u4ef6\u7cfb\u7edf\uff09 \u662f\u4e2a\u5f88\u65b0\u7684\u6587\u4ef6\u7cfb\u7edf\uff08Oracel \u57282014\u5e748\u6708\u53d1\u5e03\u7b2c\u4e00\u4e2a\u7a33\u5b9a\u7248\uff09\uff0c\u5b83\u5c06\u4f1a\u652f\u6301\u8bb8\u591a\u975e\u5e38\u9ad8\u5927\u4e0a\u7684\u529f\u80fd\uff0c\u6bd4\u5982 \u900f\u660e\u538b\u7f29\uff08 transparent compression\uff09\u3001\u53ef\u5199\u7684COW \u5feb\u7167\uff08writable copy-on-write snapshots\uff09\u3001\u53bb\u91cd\uff08deduplication \uff09\u548c\u52a0\u5bc6\uff08encryption \uff09\u3002\u56e0\u6b64\uff0cCeph \u5efa\u8bae\u7528\u6237\u5728\u975e\u5173\u952e\u5e94\u7528\u4e0a\u4f7f\u7528\u8be5\u6587\u4ef6\u7cfb\u7edf\u3002 \u66f4\u591a\u7684\u53c2\u8003\u5305\u62ec <a href=\"https:\/\/www.ibm.com\/developerworks\/cn\/linux\/l-cn-btrfs\/\">\uff081\uff09<\/a><a href=\"https:\/\/zh.wikipedia.org\/wiki\/Btrfs\">\uff082\uff09<\/a><a href=\"https:\/\/oss.oracle.com\/projects\/btrfs\/\">\uff083\uff09<\/a>\u3002<\/li>\n<li>xfs \u548c btrfs \u76f8\u6bd4\u8f83ext3\/4\u800c\u8a00\uff0c\u5728\u9ad8\u4f38\u7f29\u6027\u6570\u636e\u5b58\u50a8\u65b9\u9762\u5177\u6709\u4f18\u52bf\u3002<\/li>\n<li>Ceph \u7684<a href=\"http:\/\/docs.ceph.com\/docs\/master\/rados\/configuration\/filesystem-recommendations\/\">\u8fd9\u7bc7\u6587\u7ae0<\/a> \u660e\u786e\u63a8\u8350\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528 XFS\uff0c\u5728\u5f00\u53d1\u3001\u6d4b\u8bd5\u3001\u975e\u5173\u952e\u5e94\u7528\u4e0a\u4f7f\u7528 btrfs\u3002<\/li>\n<li>\u7f51\u4e0a\u6709\u5f88\u591a\u7684\u6587\u7ae0\u6bd4\u8f83\u8fd9\u51e0\u79cd\u6587\u4ef6\u7cfb\u7edf\uff0c\u5305\u62ec\uff1a\n<ul>\n<li><a href=\"http:\/\/www.cnblogs.com\/tommyli\/p\/3201047.html\">ext3\uff0cext4\uff0cxfs\u548cbtrfs\u6587\u4ef6\u7cfb\u7edf\u6027\u80fd\u5bf9\u6bd4<\/a><\/li>\n<li><a href=\"http:\/\/www.oschina.net\/translate\/ext4-vs-xfs-on-ssd\">\u56fa\u6001\u786c\u76d8\u4e0a Ext4 \u548c xfs \u6027\u80fd\u6bd4\u8f83<\/a><\/li>\n<li><a href=\"http:\/\/imysql.com\/2010\/08\/30\/make_your_db_faster_ext4_vs_xfs.html\">\u54c7\uff0c\u8ba9\u4f60\u7684DB\u518d\u5feb\u4e00\u500d\uff1aext4 vs xfs\u5bf9\u6bd4\u6d4b\u8bd5<\/a><\/li>\n<li><a href=\"http:\/\/arstechnica.com\/civis\/viewtopic.php?t=1169535\">XFS &#8211;if it&#8217;s more robust, why are we using ext4 instead?<\/a> <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u6587\u4ef6\u7cfb\u7edf.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u6587\u4ef6\u7cfb\u7edf.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u200b   ps\uff1awindows\u6587\u4ef6\u7cfb\u7edf\u683c\u5f0f\uff1a FAT32\u3001NTFS<\/p>\n<p>\u200b   \u603b\u7ed3<\/p>\n<pre><code class=\"language-python\">\u64cd\u4f5c\u7cfb\u7edf---------\u300b\u6587\u4ef6\u7cfb\u7edf        \u6587\u4ef6\u7cfb\u7edf          \u6587\u4ef6\u7cfb\u7edf\n\u786c\u76d8------------\u300b \u5206\u533a1           \u5206\u533a2            \u5206\u533a3<\/code><\/pre>\n<h3>7.2 \u6587\u4ef6\u7cfb\u7edf\u5de5\u4f5c\u539f\u7406<\/h3>\n<p>\u200b   \u6587\u4ef6\u7cfb\u7edf\u5982\u4f55\u5de5\u4f5c\u7684\u5462\uff1f<\/p>\n<p>\u200b   \u987b\u77e5\u4e00\u4e2a\u6587\u4ef6\u7684\u7531\u4e24\u90e8\u5206\u5185\u5bb9\u7ec4\u6210\uff1a<\/p>\n<pre><code class=\"language-python\">- 1\u3001\u6587\u4ef6\u7684\u5143\u4fe1\u606f\uff0c\u4f8b\u5982\u6743\u9650(rwx)\u3001\u62e5\u6709\u8005\u3001\u7fa4\u7ec4\u3001\u65f6\u95f4\u53c2\u6570\u7b49\u3002\n\n- 2\u3001\u6587\u4ef6\u7684\u5b9e\u9645\u5185\u5bb9<\/code><\/pre>\n<p>\u200b   <\/p>\n<p>\u200b    <strong>\u6587\u4ef6\u7cfb\u7edf\u901a\u5e38\u4f1a\u5c06\u8fd9\u4e24\u90e8\u4efd\u7684\u5206\u522b\u5b58\u653e\u5728\u4e0d\u540c\u7684\u533a\u5757<\/strong><\/p>\n<pre><code class=\"language-python\">- 1\u3001\u6587\u4ef6\u7684\u5143\u4fe1\u606f\u653e\u7f6e\u5230inode\u533a\u5757\u4e2d\n\n- 2\u3001\u6587\u4ef6\u7684\u5b9e\u9645\u5185\u5bb9\u5219\u653e\u7f6e\u5230data block\u533a\u5757\u4e2d\u3002\n\n# \u5f3a\u8c03\uff1a\u6bcf\u4e2ainode \u4e0eblock \u90fd\u6709\u81ea\u5df1\u7684\u7f16\u53f7<\/code><\/pre>\n<p>\u200b   \u53e6\u5916\uff0c\u6587\u4ef6\u8fd8\u6709\u4e00\u4e2a\u8d85\u7ea7\u533a\u5757(superblock)\u4f1a\u8bb0\u5f55\u6574\u4e2a\u6863\u6848\u7cfb\u7edf\u7684\u6574\u4f53\u4fe1\u606f\uff0c\u5305\u62ecinode\u4e0eblock\u7684\u603b\u91cf\u3001\u4f7f\u7528\u91cf\u3001\u5269\u4f59\u91cf\u7b49\u3002<\/p>\n<p>\u200b   \u8865\u5145\u8bf4\u660e\uff1a<\/p>\n<pre><code class=\"language-python\"># \u786c\u76d8\u7684\u6700\u5c0f\u5b58\u53d6\u5355\u4f4d-\u300b\u6247\u533a\n# \u64cd\u4f5c\u7cfb\u7edf\u7684\u6700\u5c0f\u5b58\u53d6\u5355\u4f4d-\u300bblock\u5757\n\n\u6587\u4ef6\u50a8\u5b58\u5728\u786c\u76d8\u4e0a\uff0c\u786c\u76d8\u7684\u6700\u5c0f\u5b58\u50a8\u5355\u4f4d\u53eb\u505a&quot;\u6247\u533a&quot;\uff08Sector\uff09\uff0c\u6bcf\u4e2a\u6247\u533a\u50a8\u5b58512\u5b57\u8282\uff08\u76f8\u5f53\u4e8e0.5KB\uff09\u3002\n\u64cd\u4f5c\u7cfb\u7edf\u8bfb\u53d6\u786c\u76d8\u7684\u65f6\u5019\uff0c\u4e0d\u4f1a\u4e00\u4e2a\u6247\u533a\u4e00\u4e2a\u6247\u533a\u5730\u8bfb\u53d6\uff0c\u8fd9\u6837\u6548\u7387\u592a\u4f4e\uff0c\u4e8e\u662f\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u6587\u4ef6\u7cfb\u7edf\u8d1f\u8d23\u5c06\u78c1\u76d8\u7684\u591a\u6247\u533a\u7ec4\u7ec7\u6210\u4e00\u4e2a\u4e2a\u7684block\u5757\uff0c\u8fd9\u6837\u64cd\u4f5c\u7cfb\u7edf\u5c31\u53ef\u4ee5\u4e00\u6b21\u6027\u8bfb\u53d6\u4e00\u4e2a&quot;\u5757&quot;\uff08block\uff09\uff0c\u5373\u4e00\u6b21\u6027\u8fde\u7eed\u8bfb\u53d6\u591a\u4e2a\u6247\u533a\u3002\u8fd9\u79cd\u7531\u591a\u4e2a\u6247\u533a\u7ec4\u6210\u7684&quot;\u5757&quot;\uff0c\u662f\u6587\u4ef6\u5b58\u53d6\u7684\u6700\u5c0f\u5355\u4f4d\u3002&quot;\u5757&quot;\u7684\u5927\u5c0f\uff0c\u6700\u5e38\u89c1\u7684\u662f4KB\uff0c\u5373\u8fde\u7eed\u516b\u4e2a sector\u7ec4\u6210\u4e00\u4e2a block\u3002<\/code><\/pre>\n<p>\u200b   <\/p>\n<p>\u200b   \u603b\u7ed3\u6587\u4ef6\u7cfb\u7edf\u7684\u4e09\u79cd\u533a\u5757inode\u3001block\u3001superblock\u7684\u610f\u4e49\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">#1\u3001superblock\uff1a\n\u8bb0\u5f55\u6b64filesystem\u7684\u6574\u4f53\u4fe1\u606f\uff0c\u5305\u62ecinode\/block\u7684\u603b\u91cf\u3001\u4f7f\u7528\u91cf\u3001\u5269\u4f59\u91cf\uff0c \u4ee5\u53ca\u6587\u4ef6\u7cfb\u7edf\u7684\u683c\u5f0f\u4e0e\u76f8\u5173\u4fe1\u606f\u7b49\uff1b\n\n#2\u3001inode\uff1a\n(1) \u8bb0\u5f55\u6587\u4ef6\u5143\u4fe1\u606f\uff0c\u5305\u62ec\u6587\u4ef6\u5bf9\u5e94\u7684\u4e00\u4e2a\u6216\u591a\u4e2ablock\u5757\u53f7\u7801\n(2) \u4e00\u4e2a\u6587\u4ef6\u88ab\u5206\u914d\u552f\u4e00\u4e00\u4e2ainode\n\n#3\u3001block\uff1a\n(1) \u8bb0\u5f55\u6587\u4ef6\u5b9e\u9645\u5185\u5bb9\n(2) \u4e00\u4e2a\u6587\u4ef6\u8fc7\u5927\u65f6\u53ef\u80fd\u4f1a\u88ab\u5206\u914d\u591a\u4e2ablock\u5feb\uff0c\u5373\u4e00\u4e2a\u6587\u4ef6\u53ef\u80fd\u5bf9\u5e94\u591a\u4e2ablock\u5757\u7684\u53f7\u7801\uff0c\u8fd9\u4e9b\u53f7\u7801\u90fd\u5b58\u653e\u5728\u8be5\u6587\u4ef6\u7684innode\u91cc<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/ext\u6587\u4ef6\u7cfb\u7edf\u7684\u526f\u672c.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/ext\u6587\u4ef6\u7cfb\u7edf\u7684\u526f\u672c.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u4e3e\u4f8b<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# ls -di \/\n64 \/\n[root@localhost ~]# ls -di \/etc\n8388673 \/etc\n[root@localhost ~]# ls -i \/etc\/passwd\n8769396 \/etc\/passwd\n[root@localhost ~]# <\/code><\/pre>\n<p>cat \/etc\/passwd\u7684\u6574\u4f53\u8fc7\u7a0b\u5982\u4e0b<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u6587\u4ef6\u7cfb\u7edf2.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u6587\u4ef6\u7cfb\u7edf2.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p>\u4f9d\u636e\u4e0a\u8ff0\u5b58\u53d6\u65b9\u5f0f\u7684\u7279\u70b9\uff0c\u6211\u4eec\u901a\u5e38\u79f0ext\u6587\u4ef6\u7cfb\u7edf\u4e3a<strong>\u7d22\u5f15\u5f0f\u6587\u4ef6\u7cfb\u7edf(indexed allocation)<\/strong>\u3002<\/p>\n<h3>7.3 \u6269\u5c55\u9605\u8bfb<\/h3>\n<h4>7.3.1 inode\u4fe1\u606f<\/h4>\n<p>\u6587\u4ef6\u7684inode\u4e2d\u6587\u8bd1\u540d\u4e3a&quot;\u7d22\u5f15\u8282\u70b9&quot;\uff0c\u662f UNIX \u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u5176\u672c\u8d28\u662f\u7ed3\u6784\u4f53\u3002<\/p>\n<p>Inode\u8d1f\u8d23\u50a8\u5b58\u6587\u4ef6\u7684\u5143\u4fe1\u606f\uff0c\u6bd4\u5982\u6587\u4ef6\u7684\u521b\u5efa\u8005\u3001\u6587\u4ef6\u7684\u521b\u5efa\u65e5\u671f\u3001\u6587\u4ef6\u7684\u5927\u5c0finode \u3002<\/p>\n<p>\u4ece\u6839\u672c\u4e0a\u8bb2\uff0c inode \u4e2d\u5b58\u653e\u7684\u662f\u9664\u4e86\u6587\u4ef6\u7684\u540d\u5b57\u4ee5\u53ca\u6587\u4ef6\u771f\u5b9e\u5185\u5bb9\u4e4b\u5916\u3001\u6240\u6709\u6709\u5173\u6587\u4ef6\u7684\u4fe1\u606f\/\u5143\u6570\u636e(metadata)\uff0c\u5982\u4e0b<\/p>\n<pre><code class=\"language-python\">\u25cf inode \u7f16\u53f7\n\u25cf \u7528\u6765\u8bc6\u522b\u6587\u4ef6\u7c7b\u578b\uff0c\u4ee5\u53ca\u7528\u4e8e stat C \u51fd\u6570\u7684\u6a21\u5f0f\u4fe1\u606f\n\u25cf \u94fe\u63a5\u6570\uff0c\u5373\u6709\u591a\u5c11\u6587\u4ef6\u540d\u6307\u5411\u8fd9\u4e2ainode\u3002\n\u25cf \u5c5e\u4e3b\u7684ID (UID)\n\u25cf \u5c5e\u4e3b\u7684\u7ec4 ID (GID)\n\u25cf \u6587\u4ef6\u7684\u5b57\u8282\u6570\n\u25cf \u6587\u4ef6\u6240\u4f7f\u7528\u7684\u78c1\u76d8\u5757\u7684\u5b9e\u9645\u6570\u76ee\n\u25cf \u6587\u4ef6\u7684\u65f6\u95f4\u6233\uff0c\u5171\u6709\u4e09\u4e2a\uff1actime\u6307inode\u4e0a\u4e00\u6b21\u53d8\u52a8\u7684\u65f6\u95f4\uff0cmtime\u6307\u6587\u4ef6\u5185\u5bb9\u4e0a\u4e00\u6b21\u53d8\u52a8\u7684\u65f6\u95f4\uff0catime\u6307\u6587\u4ef6\u4e0a\u4e00\u6b21\u6253\u5f00\u7684\u65f6\u95f4\u3002\n\u25cf \u6307\u5411\u6570\u636e\u5757\u7684\u6307\u9488 <\/code><\/pre>\n<p>\u53ef\u4ee5\u7528stat\u547d\u4ee4\uff0c\uff0c\u67e5\u770b\u67d0\u4e2a\u6587\u4ef6\u7684inode\u4fe1\u606f\uff1a<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# stat egon.txt \n  \u6587\u4ef6\uff1a&quot;egon.txt&quot;\n  \u5927\u5c0f\uff1a0          \u5757\uff1a0          IO \u5757\uff1a4096   \u666e\u901a\u7a7a\u6587\u4ef6\n\u8bbe\u5907\uff1a803h\/2051d   Inode\uff1a16813492    \u786c\u94fe\u63a5\uff1a1\n\u6743\u9650\uff1a(0644\/-rw-r--r--)  Uid\uff1a(    0\/    root)   Gid\uff1a(    0\/    root)\n\u6700\u8fd1\u8bbf\u95ee\uff1a2022-12-16 16:25:29.664259627 +0800\n\u6700\u8fd1\u66f4\u6539\uff1a2022-12-16 16:25:29.664259627 +0800\n\u6700\u8fd1\u6539\u52a8\uff1a2022-12-16 16:25:29.664259627 +0800\n\u521b\u5efa\u65f6\u95f4\uff1a-\n\n# \u4e09\u79cd\u65f6\u95f4\u89e3\u91ca\natime \uff1a access time \u8bbf\u95ee\u6587\u4ef6\u5185\u5bb9\u7684\u65f6\u95f4\u3002\u5bf9\u6587\u4ef6\u8fdb\u884c\u4e00\u6b21\u8bfb\u64cd\u4f5c\uff0c\u5b83\u7684\u8bbf\u95ee\u65f6\u95f4\u5c31\u4f1a\u6539\u53d8\u3002\u4f8b\u5982\u50cf\uff1acat\u3001more\u7b49\u64cd\u4f5c\uff0c\u4f46\u662f\u50cf\u4e4b\u524d\u7684stat\u8fd8\u6709ls\u547d\u4ee4\u5bf9atime\u662f\u4e0d\u4f1a\u6709\u5f71\u54cd\u7684\u3002\n\nmtime \uff1a modify time \u4fee\u6539\u6587\u4ef6\u5185\u5bb9\u7684\u65f6\u95f4\u3002\u6587\u4ef6\u7684\u5185\u5bb9\u88ab\u6700\u540e\u4e00\u6b21\u4fee\u6539\u7684\u65f6\u95f4\uff0c\u6211\u4eec\u7ecf\u5e38\u7528\u7684ls -l\u547d\u4ee4\u663e\u793a\u51fa\u6765\u7684\u6587\u4ef6\u65f6\u95f4\u5c31\u662f\u8fd9\u4e2a\u65f6\u95f4\uff0c\u5f53\u7528vim\u5bf9\u6587\u4ef6\u8fdb\u884c\u7f16\u8f91\u4e4b\u540e\u4fdd\u5b58\uff0c\u5b83\u7684mtime\u5c31\u4f1a\u76f8\u5e94\u7684\u6539\u53d8\uff1b\u6bd4\u5982\uff1a\u5982\uff1aecho aa &gt;&gt; a.sh \u6216vim a.txt \u4fee\u6539\u5185\u5bb9\n\nctime \uff1a change time \u6307inode\u4e0a\u4e00\u6b21\u6587\u4ef6\u5c5e\u6027\u53d8\u52a8\u7684\u65f6\u95f4\u3002\u5f53\u6587\u4ef6\u7684\u72b6\u6001\u88ab\u6539\u53d8\u7684\u65f6\u5019\uff0c\u72b6\u6001\u65f6\u95f4\u5c31\u4f1a\u968f\u4e4b\u6539\u53d8\uff0c\u4f8b\u5982\u5f53\u4f7f\u7528chmod\u3001chown\u7b49\u6539\u53d8\u6587\u4ef6\u5c5e\u6027\u7684\u64cd\u4f5c\u662f\u4f1a\u6539\u53d8\u6587\u4ef6\u7684ctime\u7684\u3002chmod +x a.txt<\/code><\/pre>\n<p>\u4f8b1\uff1a\u4f7f\u7528cat\u547d\u4ee4\u67e5\u770b\u6587\u4ef6\u540e\uff0c\u6587\u4ef6atime\u53d8\u66f4<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# touch egon.txt\n[root@localhost ~]# stat egon.txt \n  \u6587\u4ef6\uff1a&quot;egon.txt&quot;\n  \u5927\u5c0f\uff1a0          \u5757\uff1a0          IO \u5757\uff1a4096   \u666e\u901a\u7a7a\u6587\u4ef6\n\u8bbe\u5907\uff1a803h\/2051d   Inode\uff1a16813492    \u786c\u94fe\u63a5\uff1a1\n\u6743\u9650\uff1a(0644\/-rw-r--r--)  Uid\uff1a(    0\/    root)   Gid\uff1a(    0\/    root)\n\u6700\u8fd1\u8bbf\u95ee\uff1a2022-12-16 16:25:29.664259627 +0800\n\u6700\u8fd1\u66f4\u6539\uff1a2022-12-16 16:25:29.664259627 +0800\n\u6700\u8fd1\u6539\u52a8\uff1a2022-12-16 16:25:29.664259627 +0800\n\u521b\u5efa\u65f6\u95f4\uff1a-\n[root@localhost ~]# cat egon.txt \n[root@localhost ~]# stat egon.txt \n  \u6587\u4ef6\uff1a&quot;egon.txt&quot;\n  \u5927\u5c0f\uff1a0          \u5757\uff1a0          IO \u5757\uff1a4096   \u666e\u901a\u7a7a\u6587\u4ef6\n\u8bbe\u5907\uff1a803h\/2051d   Inode\uff1a16813492    \u786c\u94fe\u63a5\uff1a1\n\u6743\u9650\uff1a(0644\/-rw-r--r--)  Uid\uff1a(    0\/    root)   Gid\uff1a(    0\/    root)\n\u6700\u8fd1\u8bbf\u95ee\uff1a2022-12-16 16:29:26.162262768 +0800\n\u6700\u8fd1\u66f4\u6539\uff1a2022-12-16 16:25:29.664259627 +0800\n\u6700\u8fd1\u6539\u52a8\uff1a2022-12-16 16:25:29.664259627 +0800\n\u521b\u5efa\u65f6\u95f4\uff1a-\n[root@localhost ~]# <\/code><\/pre>\n<p>\u4f8b2\uff1a\u4f7f\u7528vim\u547d\u4ee4\u5199\u6587\u4ef6w\u540e\uff0c\u6587\u4ef6atime\u3001mtime\u3001ctime\u90fd\u4f1a\u53d8\u66f4\u3002\u5982\u679cvim\u6253\u5f00\u540e\u53ea\u662f\u67e5\u770b\u6ca1\u6709\u5199\u7684\u8bdd\uff0c\u53ea\u4f1a\u53d8\u66f4atime\u3002<\/p>\n<pre><code class=\"language-python\">\u7565<\/code><\/pre>\n<p>\u4f8b3\uff1a<\/p>\n<pre><code class=\"language-python\">[root@localhost ~]# stat egon.txt \n  \u6587\u4ef6\uff1a&quot;egon.txt&quot;\n  \u5927\u5c0f\uff1a9          \u5757\uff1a8          IO \u5757\uff1a4096   \u666e\u901a\u6587\u4ef6\n\u8bbe\u5907\uff1a803h\/2051d   Inode\uff1a17696455    \u786c\u94fe\u63a5\uff1a1\n\u6743\u9650\uff1a(0644\/-rw-r--r--)  Uid\uff1a(    0\/    root)   Gid\uff1a(    0\/    root)\n\u6700\u8fd1\u8bbf\u95ee\uff1a2022-12-16 16:35:21.943267492 +0800\n\u6700\u8fd1\u66f4\u6539\uff1a2022-12-16 16:35:46.131267813 +0800\n\u6700\u8fd1\u6539\u52a8\uff1a2022-12-16 16:35:46.131267813 +0800\n\u521b\u5efa\u65f6\u95f4\uff1a-\n[root@localhost ~]# chmod 000 egon.txt \n[root@localhost ~]# stat egon.txt \n  \u6587\u4ef6\uff1a&quot;egon.txt&quot;\n  \u5927\u5c0f\uff1a9          \u5757\uff1a8          IO \u5757\uff1a4096   \u666e\u901a\u6587\u4ef6\n\u8bbe\u5907\uff1a803h\/2051d   Inode\uff1a17696455    \u786c\u94fe\u63a5\uff1a1\n\u6743\u9650\uff1a(0000\/----------)  Uid\uff1a(    0\/    root)   Gid\uff1a(    0\/    root)\n\u6700\u8fd1\u8bbf\u95ee\uff1a2022-12-16 16:35:21.943267492 +0800\n\u6700\u8fd1\u66f4\u6539\uff1a2022-12-16 16:35:46.131267813 +0800\n\u6700\u8fd1\u6539\u52a8\uff1a2022-12-16 16:36:43.423268574 +0800\n\u521b\u5efa\u65f6\u95f4\uff1a-\n[root@localhost ~]# \n<\/code><\/pre>\n<h4>7.3.2 inode\u7684\u5927\u5c0f<\/h4>\n<p>inode\u4e5f\u4f1a\u6d88\u8017\u786c\u76d8\u7a7a\u95f4\uff0c\u6240\u4ee5\u786c\u76d8\u683c\u5f0f\u5316\u7684\u65f6\u5019\uff0c\u64cd\u4f5c\u7cfb\u7edf\u81ea\u52a8\u5c06\u786c\u76d8\u5206\u6210\u4e24\u4e2a\u533a\u57df\u3002\u4e00\u4e2a\u662f\u6570\u636e\u533a\uff0c\u5b58\u653e\u6587\u4ef6\u6570\u636e\uff1b\u53e6\u4e00\u4e2a\u662finode\u533a\uff08inode table\uff09\uff0c\u5b58\u653einode\u6240\u5305\u542b\u7684\u4fe1\u606f\u3002<\/p>\n<p>\u6bcf\u4e2ainode\u8282\u70b9\u7684\u5927\u5c0f\uff0c\u4e00\u822c\u662f128\u5b57\u8282\u6216256\u5b57\u8282\u3002inode\u8282\u70b9\u7684\u603b\u6570\uff0c\u5728\u683c\u5f0f\u5316\u65f6\u5c31\u7ed9\u5b9a\uff0c\u4e00\u822c\u662f\u6bcf1KB\u6216\u6bcf2KB\u5c31\u8bbe\u7f6e\u4e00\u4e2ainode\u3002\u5047\u5b9a\u5728\u4e00\u57571GB\u7684\u786c\u76d8\u4e2d\uff0c\u6bcf\u4e2ainode\u8282\u70b9\u7684\u5927\u5c0f\u4e3a128\u5b57\u8282\uff0c\u6bcf1KB\u5c31\u8bbe\u7f6e\u4e00\u4e2ainode\uff0c\u90a3\u4e48inode table\u7684\u5927\u5c0f\u5c31\u4f1a\u8fbe\u5230128MB\uff0c\u5360\u6574\u5757\u786c\u76d8\u768412.8%\u3002<\/p>\n<p>\u67e5\u770b\u6bcf\u4e2a\u786c\u76d8\u5206\u533a\u7684inode\u603b\u6570\u548c\u5df2\u7ecf\u4f7f\u7528\u7684\u6570\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528df -i \u547d\u4ee4\u3002<\/p>\n<p>\u67e5\u770b\u6bcf\u4e2ainode\u8282\u70b9\u7684\u5927\u5c0f\uff0c\u53ef\u4ee5\u7528\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-python\"># \u67e5\u770bext\u6587\u4ef6\u7cfb\u7edf\u4fe1\u606f\nsudo dumpe2fs -h \/dev\/hda | grep &quot;Inode size&quot;\n\n# \u67e5\u770bxfs\u6587\u4ef6\u7cfb\u7edf\u4fe1\u606f\nxfs_info \/dev\/sda1\n\n[root@localhost ~]# xfs_info \/dev\/sda1\n# isize\u8868\u793a\u4e3ainode\u5927\u5c0f\uff1bagcount\u4e3a\u5b58\u50a8\u533a\u7fa4\u7ec4(allocation group)\u7684\u4e2a\u6570\uff1b\nmeta-data=\/dev\/sda1              isize=512    agcount=4, agsize=65536 blks\n# sectsz\u6307\u903b\u8f91\u6247\u533a(sector)\u7684\u5bb9\u91cf\u5927\u5c0f\uff1b\n         =                       sectsz=512   attr=2, projid32bit=1\n         =                       crc=1        finobt=0 spinodes=0\n# bsize\u6307block\u5bb9\u91cf\u5927\u5c0f\uff1b\ndata     =                       bsize=4096   blocks=262144, imaxpct=25\n# sunit\u4e0eswidth\u4e0estripe\u76f8\u5173\n         =                       sunit=0      swidth=0 blks\nnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1\n# internal\u6307\u767b\u5f55\u533a(log p)\u5728\u6587\u4ef6\u7cfb\u7edf\u5185\u90e8\uff0c\u800c\u4e0d\u5728\u5916\u90e8\n# bsize\u6307\u5360\u7528\u533a\u5757\u5927\u5c0f\uff0cblocks\u4e3a\u6570\u91cf\uff1b\nlog      =internal               bsize=4096   blocks=2560, version=2\n         =                       sectsz=512   sunit=0 blks, lazy-count=1\n# realtiem p\u533a\u57df\u4fe1\u606f\uff1bextsz\u6307extent size\uff1b\nrealtime =none                   extsz=4096   blocks=0, rtextents=0<\/code><\/pre>\n<p>\u7531\u4e8e\u6bcf\u4e2a\u6587\u4ef6\u90fd\u5fc5\u987b\u6709\u4e00\u4e2ainode\uff0c\u56e0\u6b64\u6709\u53ef\u80fd\u53d1\u751finode\u5df2\u7ecf\u7528\u5149\uff0c\u4f46\u662f\u786c\u76d8\u8fd8\u672a\u5b58\u6ee1\u7684\u60c5\u51b5\u3002\u8fd9\u65f6\uff0c\u5c31\u65e0\u6cd5\u5728\u786c\u76d8\u4e0a\u521b\u5efa\u65b0\u6587\u4ef6\u3002<\/p>\n<h4>7.3.3 inode\u53f7\u7801<\/h4>\n<p>\u6bcf\u4e2ainode\u90fd\u6709\u4e00\u4e2a\u53f7\u7801\uff0c\u64cd\u4f5c\u7cfb\u7edf\u7528inode\u53f7\u7801\u6765\u8bc6\u522b\u4e0d\u540c\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u8fd9\u91cc\u503c\u5f97\u91cd\u590d\u4e00\u904d\uff0cLinux\u7cfb\u7edf\u5185\u90e8\u4e0d\u4f7f\u7528\u6587\u4ef6\u540d\uff0c\u800c\u4f7f\u7528inode\u53f7\u7801\u6765\u8bc6\u522b\u6587\u4ef6\u3002\u5bf9\u4e8e\u7cfb\u7edf\u6765\u8bf4\uff0c\u6587\u4ef6\u540d\u53ea\u662finode\u53f7\u7801\u4fbf\u4e8e\u8bc6\u522b\u7684\u522b\u79f0\u6216\u8005\u7ef0\u53f7\u3002\u8868\u9762\u4e0a\uff0c\u7528\u6237\u901a\u8fc7\u6587\u4ef6\u540d\uff0c\u6253\u5f00\u6587\u4ef6\u3002\u5b9e\u9645\u4e0a\uff0c\u7cfb\u7edf\u5185\u90e8\u8fd9\u4e2a\u8fc7\u7a0b\u5206\u6210\u4e09\u6b65\uff1a<\/p>\n<ul>\n<li>\u9996\u5148\uff0c\u7cfb\u7edf\u627e\u5230\u8fd9\u4e2a\u6587\u4ef6\u540d\u5bf9\u5e94\u7684inode\u53f7\u7801\uff1b<\/li>\n<li>\u5176\u6b21\uff0c\u901a\u8fc7inode\u53f7\u7801\uff0c\u83b7\u53d6inode\u4fe1\u606f\uff1b<\/li>\n<li>\u6700\u540e\uff0c\u6839\u636einode\u4fe1\u606f\uff0c\u627e\u5230\u6587\u4ef6\u6570\u636e\u6240\u5728\u7684block\uff0c\u8bfb\u51fa\u6570\u636e\u3002<\/li>\n<\/ul>\n<p>\u4f7f\u7528ls -i\u547d\u4ee4\uff0c\u53ef\u4ee5\u770b\u5230\u6587\u4ef6\u540d\u5bf9\u5e94\u7684inode\u53f7\u7801\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code>ls -i demo.txt<\/code><\/pre>\n<h4>7.3.4 \u76ee\u5f55\u9879<\/h4>\n<p>Linux\u7cfb\u7edf\u4e2d\uff0c\u76ee\u5f55\uff08directory\uff09\u4e5f\u662f\u4e00\u79cd\u6587\u4ef6\u3002\u6253\u5f00\u76ee\u5f55\uff0c\u5b9e\u9645\u4e0a\u5c31\u662f\u6253\u5f00\u76ee\u5f55\u6587\u4ef6\u3002<\/p>\n<p>\u76ee\u5f55\u6587\u4ef6\u7684\u7ed3\u6784\u975e\u5e38\u7b80\u5355\uff0c\u5c31\u662f\u4e00\u7cfb\u5217\u76ee\u5f55\u9879\uff08dirent\uff09\u7684\u5217\u8868\u3002\u6bcf\u4e2a\u76ee\u5f55\u9879\uff0c\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u6240\u5305\u542b\u6587\u4ef6\u7684\u6587\u4ef6\u540d\uff0c\u4ee5\u53ca\u8be5\u6587\u4ef6\u540d\u5bf9\u5e94\u7684inode\u53f7\u7801\u3002<\/p>\n<p>ls\u547d\u4ee4\u53ea\u5217\u51fa\u76ee\u5f55\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u540d\uff1a<\/p>\n<pre><code>ls \/etc<\/code><\/pre>\n<p>ls -i\u547d\u4ee4\u5217\u51fa\u6574\u4e2a\u76ee\u5f55\u6587\u4ef6\uff0c\u5373\u6587\u4ef6\u540d\u548cinode\u53f7\u7801\uff1a<\/p>\n<pre><code>ls -i \/etc<\/code><\/pre>\n<p>\u5982\u679c\u8981\u67e5\u770b\u6587\u4ef6\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5c31\u5fc5\u987b\u6839\u636einode\u53f7\u7801\uff0c\u8bbf\u95eeinode\u8282\u70b9\uff0c\u8bfb\u53d6\u4fe1\u606f\u3002ls -l\u547d\u4ee4\u5217\u51fa\u6587\u4ef6\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<pre><code>ls -l \/etc<\/code><\/pre>\n<h4>7.3.5 FAT\u6587\u4ef6\u7cfb\u7edf<\/h4>\n<p>U\u76d8\u4f7f\u7528\u7684\u6863\u6848\u7cfb\u7edf\u4e00\u822c\u4e3aFAT\u683c\u5f0f\u3002FAT\u8fd9\u79cd\u683c\u5f0f\u7684\u6863\u6848\u7cfb\u7edf\u5e76\u6ca1\u6709inode\u5b58\u5728\uff0c\u6240\u4ee5FAT\u6ca1\u6709\u529e\u6cd5\u5c06\u8fd9\u4e2a\u6863\u6848\u7684\u6240\u6709block\u5728\u4e00\u5f00\u59cb\u5c31\u8bfb\u53d6\u51fa\u6765\u3002\u6bcf\u4e2ablock\u53f7\u7801\u90fd\u8bb0\u5f55\u5728\u524d\u4e00\u4e2ablock\u5f53\u4e2d\uff0c\u4ed6\u7684\u8bfb\u53d6\u65b9\u5f0f\u6709\u70b9\u50cf\u5e95\u4e0b\u8fd9\u6837\uff1a<\/p>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/image-1710568552544.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/image-1710568552544.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"file\" \/><\/div><\/p>\n<p>\u4e0a\u56fe\u4e2d\u6211\u4eec\u5047\u8bbe\u6863\u6848\u7684\u8d44\u6599\u4f9d\u5e8f\u5199\u5165<strong>1-&gt;7-&gt;4-&gt;15<\/strong>\u53f7\u8fd9\u56db\u4e2ablock \u53f7\u7801\u4e2d\uff0c \u4f46\u8fd9\u4e2a\u6863\u6848\u7cfb\u7edf\u6ca1\u6709\u529e\u6cd5\u4e00\u53e3\u6c14\u5c31\u77e5\u9053\u56db\u4e2ablock \u7684\u53f7\u7801\uff0c\u4ed6\u5f97\u8981\u4e00\u4e2a\u4e00\u4e2a\u7684\u5c06block \u8bfb\u51fa\u540e\uff0c\u624d\u4f1a\u77e5\u9053\u4e0b\u4e00\u4e2ablock \u5728\u4f55\u5904\u3002\u5982\u679c\u540c\u4e00\u4e2a\u6863\u6848\u8d44\u6599\u5199\u5165\u7684block \u5206\u6563\u7684\u592a\u8fc7\u5389\u5bb3\u65f6\uff0c\u5219\u6211\u4eec\u7684\u78c1\u76d8\u8bfb\u53d6\u5934\u5c06\u65e0\u6cd5\u5728\u78c1\u76d8\u8f6c\u4e00\u5708\u5c31\u8bfb\u5230\u6240\u6709\u7684\u8d44\u6599\uff0c \u56e0\u6b64\u78c1\u76d8\u5c31\u4f1a\u591a\u8f6c\u597d\u51e0\u5708\u624d\u80fd\u5b8c\u6574\u7684\u8bfb\u53d6\u5230\u8fd9\u4e2a\u6863\u6848\u7684\u5185\u5bb9\uff01<\/p>\n<p>\u5e38\u5e38\u4f1a\u542c\u5230\u6240\u8c13\u7684\u300e\u788e\u7247\u6574\u7406\u300f\u5427<strong>\uff1f \u9700\u8981\u788e\u7247\u6574\u7406\u7684\u539f\u56e0\u5c31\u662f\u6863\u6848\u5199\u5165\u7684block\u592a\u8fc7\u4e8e\u79bb\u6563\u4e86\uff0c\u6b64\u65f6\u6863\u6848\u8bfb\u53d6\u7684\u6548\u80fd\u5c06\u4f1a\u53d8\u7684\u5f88\u5dee\u6240\u81f4\u3002 \u8fd9\u4e2a\u65f6\u5019\u53ef\u4ee5\u900f\u8fc7\u788e\u7247\u6574\u7406\u5c06\u540c\u4e00\u4e2a\u6863\u6848\u6240\u5c5e\u7684blocks\u6c47\u6574\u5728\u4e00\u8d77\uff0c\u8fd9\u6837\u8d44\u6599\u7684\u8bfb\u53d6\u4f1a\u6bd4\u8f83\u5bb9\u6613\u554a\uff01<\/strong> \u60f3\u5f53\u7136\u5c14\uff0cFAT\u7684\u6863\u6848\u7cfb\u7edf\u9700\u8981\u4e09\u4e0d\u4e94\u65f6\u7684\u788e\u7247\u6574\u7406\u4e00\u4e0b\uff0c\u90a3\u4e48Ext2\u662f\u5426\u9700\u8981\u78c1\u76d8\u91cd\u6574\u5462\uff1f<\/p>\n<p>\u7531\u4e8eExt2 \u662f\u7d22\u5f15\u5f0f\u6863\u6848\u7cfb\u7edf\uff0c\u57fa\u672c\u4e0a\u4e0d\u592a\u9700\u8981\u5e38\u5e38\u8fdb\u884c\u788e\u7247\u6574\u7406\u7684\u3002\u4f46\u662f\u5982\u679c\u6863\u6848\u7cfb\u7edf\u4f7f\u7528\u592a\u4e45\uff0c \u5e38\u5e38\u5220\u9664\/\u7f16\u8f91\/\u65b0\u589e\u6863\u6848\u65f6\uff0c\u90a3\u4e48\u8fd8\u662f\u53ef\u80fd\u4f1a\u9020\u6210\u6863\u6848\u8d44\u6599\u592a\u8fc7\u4e8e\u79bb\u6563\u7684\u95ee\u9898\uff0c\u6b64\u65f6\u6216\u8bb8\u4f1a\u9700\u8981\u8fdb\u884c\u91cd\u6574\u4e00\u4e0b\u7684\u3002<\/p>\n<h3>7.4 Inode\u7684\u7279\u6b8a\u4f5c\u7528<\/h3>\n<p>\u7531\u4e8einode\u53f7\u7801\u4e0e\u6587\u4ef6\u540d\u5206\u79bb\uff0c\u8fd9\u79cd\u673a\u5236\u5bfc\u81f4\u4e86\u4e00\u4e9bUnix\/Linux\u7cfb\u7edf\u7279\u6709\u7684\u73b0\u8c61\u3002<\/p>\n<ol>\n<li>\u6709\u65f6\uff0c\u6587\u4ef6\u7279\u522b\u7279\u522b\u7684\u5927\uff0c\u6216\u8005\u78c1\u76d8IO\u7e41\u5fd9\uff0c\u4f60\u76f4\u63a5\u7528rm -rf\u5220\u9664\u7684\u8bdd\u4f1a\u975e\u5e38\u6162\uff0c\u8fdb\u800c\u5f71\u54cd\u5176\u4ed6\u8fdb\u7a0b\u7684\u6b63\u5e38\u8fd0\u884c\u3002\u5982\u4f55\u5904\u7406\u5462\uff1f\u601d\u8def\u5c31\u5728\u4e8einode\u5757\u4e0a\uff0cinode\u4e2d\u5b58\u7740\u6587\u4ef6\u7684\u5143\u6570\u636e\uff08\u4f8b\u5982\uff0c\u6587\u4ef6\u5927\u5c0f\u3001\u6240\u6709\u8005ID\u3001\u7ec4ID\u3001\u6587\u4ef6\u6743\u9650\u3001\u65f6\u95f4\u6233\u7b49\uff09\n<pre><code>\n\u6b64\u65f6\u6211\u4eec\u53ef\u4ee5\u8003\u8651\u4f7f\u7528truncate\u547d\u4ee4\u6765\u66ff\u6362rm\u547d\u4ee4\ntruncate -s 0 \/path\/to\/your\/large\/file<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>truncate\u547d\u4ee4\u5de5\u4f5c\u65f6\uff0c\u4f1a\u76f4\u63a5\u4fee\u6539inode\u4e2d\u8bb0\u5f55\u7684\u6587\u4ef6\u5927\u5c0f\uff0c\u5c06\u5176\u8bbe\u7f6e\u4e3a0\uff0c\u800c\u5e76\u4e0d\u4f1a\u53bb\u89e6\u53ca\u5230\u6587\u4ef6\u5185\u5bb9\u6240\u5728\u7684\u6570\u636e\u5757\u3002\u6240\u4ee5\u78c1\u76d8IO\u6d88\u8017\u6781\u5c0f\uff0c\u901f\u5ea6\u6781\u5feb\u3002<\/p>\n<p>\u8bbe\u4e3a0\u4e4b\u540e\uff0c\u4f60\u518d\u7528rm\u547d\u4ee4\u628a\u8fd9\u8fd9\u4e2a\u7a7a\u6587\u4ef6\u5220\u6389\u5c31\u884c<\/p>\n<pre><code>2. \u79fb\u52a8\u6587\u4ef6\u6216\u91cd\u547d\u540d\u6587\u4ef6\uff0c\u53ea\u662f\u6539\u53d8\u6587\u4ef6\u540d\uff0c\u4e0d\u5f71\u54cdinode\u53f7\u7801\u3002\n\n3. \u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u4ee5\u540e\uff0c\u7cfb\u7edf\u5c31\u4ee5inode\u53f7\u7801\u6765\u8bc6\u522b\u8fd9\u4e2a\u6587\u4ef6\uff0c\u4e0d\u518d\u8003\u8651\u6587\u4ef6\u540d\u3002\u56e0\u6b64\uff0c\u901a\u5e38\u6765\u8bf4\uff0c\u7cfb\u7edf\u65e0\u6cd5\u4eceinode\u53f7\u7801\u5f97\u77e5\u6587\u4ef6\u540d\u3002\n\n   ```python\n   [root@localhost ~]# ls -i egon.txt \n   17696455 egon.txt\n   [root@localhost ~]# vim egon.txt  # vim\u7f16\u8f91\u5668\u5199\u6587\u4ef6\uff0c\u4f1a\u6539\u53d8inode\u53f7\n   [root@localhost ~]# ls -i egon.txt \n   17696461 egon.txt\n   [root@localhost ~]# \n   [root@localhost ~]# mv egon.txt EGON.txt  # \u91cd\u547d\u540d\u6587\u4ef6\u4e0d\u4f1a\u5f71\u54cdinode\u53f7\n   [root@localhost ~]# ls -i EGON.txt \n   17696461 EGON.txt\n   [root@localhost ~]# <\/code><\/pre>\n<p>\u95ee\uff1a\u4e3a\u4ec0\u4e48\u6bcf\u6b21\u4fee\u6539\u5b8c\u670d\u52a1\u5668\u914d\u7f6e\u6587\u4ef6\u540e\uff0c\u90fd\u9700\u8981\u91cd\u65b0\u52a0\u8f7d\u4e00\u4e0b\u914d\u7f6e\u6587\u4ef6\uff1f<\/p>\n<p>\u7b54\uff1a\u56e0\u4e3avim\u6bcf\u6b21\u4fee\u6539\u5b8c\u540e\uff0cInode\u53f7\u90fd\u4f1a\u53d8,\u7cfb\u7edf\u8fd8\u662f\u8bfb\u53d6\u7684\u539f\u6765inode\u53f7\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u6bcf\u6b21\u4fee\u6539\u5b8c\u670d\u52a1\u5668\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u90fd\u8981\u91cd\u542f\u670d\u52a1\uff0c\u91cd\u65b0\u8bfb\u4e00\u4e0b\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<h3>7.5 \u786c\u94fe\u63a5\u548c\u8f6f\u94fe\u63a5<\/h3>\n<p>Linux\u94fe\u63a5\u5206\u4e24\u79cd<\/p>\n<ul>\n<li>\n<p>1\u3001\u4e00\u79cd\u88ab\u79f0\u4e3a\u786c\u94fe\u63a5\uff08Hard Link\uff09<\/p>\n<pre><code class=\"language-python\">\u3010\u786c\u8fde\u63a5\u3011\uff1a\u786c\u8fde\u63a5\u6307\u901a\u8fc7\u7d22\u5f15\u8282\u70b9\u53f7\u6765\u8fdb\u884c\u8fde\u63a5\u3002inode\u662f\u53ef\u4ee5\u5bf9\u5e94\u591a\u4e2a\u6587\u4ef6\u540d\u7684\n\n# \u6269\u5c55\u9605\u8bfb\ninode\u4fe1\u606f\u4e2d\u6709\u4e00\u9879\u53eb\u505a\"\u94fe\u63a5\u6570\"\uff0c\u8bb0\u5f55\u6307\u5411\u8be5inode\u7684\u6587\u4ef6\u540d\u603b\u6570\uff0c\u8fd9\u65f6\u5c31\u4f1a\u589e\u52a01\u3002\u53cd\u8fc7\u6765\uff0c\u5220\u9664\u4e00\u4e2a\u6587\u4ef6\u540d\uff0c\u5c31\u4f1a\u4f7f\u5f97inode\u8282\u70b9\u4e2d\u7684\"\u94fe\u63a5\u6570\"\u51cf1\u3002\u5f53\u8fd9\u4e2a\u503c\u51cf\u52300\uff0c\u8868\u660e\u6ca1\u6709\u6587\u4ef6\u540d\u6307\u5411\u8fd9\u4e2ainode\uff0c\u7cfb\u7edf\u5c31\u4f1a\u56de\u6536\u8fd9\u4e2ainode\u53f7\u7801\uff0c\u4ee5\u53ca\u5176\u6240\u5bf9\u5e94block\u533a\u57df\u3002\n\n\u8fd9\u91cc\u987a\u4fbf\u8bf4\u4e00\u4e0b\u76ee\u5f55\u6587\u4ef6\u7684\"\u94fe\u63a5\u6570\"\u3002\u521b\u5efa\u76ee\u5f55\u65f6\uff0c\u9ed8\u8ba4\u4f1a\u751f\u6210\u4e24\u4e2a\u76ee\u5f55\u9879\uff1a\".\"\u548c\"..\"\u3002\u524d\u8005\u7684inode\u53f7\u7801\u5c31\u662f\u5f53\u524d\u76ee\u5f55\u7684inode\u53f7\u7801\uff0c\u7b49\u540c\u4e8e\u5f53\u524d\u76ee\u5f55\u7684\"\u786c\u94fe\u63a5\"\uff1b\u540e\u8005\u7684inode\u53f7\u7801\u5c31\u662f\u5f53\u524d\u76ee\u5f55\u7684\u7236\u76ee\u5f55\u7684inode\u53f7\u7801\uff0c\u7b49\u540c\u4e8e\u7236\u76ee\u5f55\u7684\"\u786c\u94fe\u63a5\"\u3002\u6240\u4ee5\uff0c\u4efb\u4f55\u4e00\u4e2a\u76ee\u5f55\u7684\"\u786c\u94fe\u63a5\"\u603b\u6570\uff0c\u603b\u662f\u7b49\u4e8e2\u52a0\u4e0a\u5b83\u7684\u5b50\u76ee\u5f55\u603b\u6570\uff08\u542b\u9690\u85cf\u76ee\u5f55\uff09,\u8fd9\u91cc\u76842\u662f\u7236\u76ee\u5f55\u5bf9\u5176\u7684\u201c\u786c\u94fe\u63a5\u201d\u548c\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\".\u786c\u94fe\u63a5\u201c\u3002<\/code><\/pre>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u786c\u94fe\u63a5.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u786c\u94fe\u63a5.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<\/li>\n<li>\n<p>2\u3001\u53e6\u4e00\u79cd\u88ab\u79f0\u4e3a\u8f6f\u94fe\u63a5\uff0c\u5373\u7b26\u53f7\u94fe\u63a5\uff08Symbolic Link\uff09<\/p>\n<pre><code class=\"language-python\">\u8f6f\u94fe\u63a5\u6587\u4ef6\u6709\u7c7b\u4f3c\u4e8eWindows\u7684\u5feb\u6377\u65b9\u5f0f\u3002\u5b83\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u6587\u4ef6\u3002\u5728\u7b26\u53f7\u8fde\u63a5\u4e2d\uff0c\u6587\u4ef6\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u7684\u6709\u53e6\u4e00\u6587\u4ef6\u7684\u4f4d\u7f6e\u4fe1\u606f\u3002\n\n\u5982\u4e0b\u56fe\u6240\u793a\n\u6587\u4ef62\u548c\u6587\u4ef61\u7684inode\u53f7\u7801\u867d\u7136\u4e0d\u4e00\u6837\uff0c\u4f46\u662f\u6587\u4ef62\u7684\u5185\u5bb9\u662f\u6587\u4ef61\u7684\u8def\u5f84\u3002\u8bfb\u53d6\u6587\u4ef62\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5c06\u8bbf\u95ee\u8005\u5bfc\u5411\u6587\u4ef61\u3002\u56e0\u6b64\uff0c\u65e0\u8bba\u6253\u5f00\u54ea\u4e00\u4e2a\u6587\u4ef6\uff0c\u6700\u7ec8\u8bfb\u53d6\u7684\u90fd\u662f\u6587\u4ef61\u3002\u8fd9\u65f6\uff0c\u6587\u4ef62\u5c31\u79f0\u4e3a\u6587\u4ef61\u7684\"\u8f6f\u94fe\u63a5\"\uff08soft link\uff09\u6216\u8005\"\u7b26\u53f7\u94fe\u63a5\uff08symbolic link\uff09\u3002\n\n\u8fd9\u610f\u5473\u7740\uff0c\u6587\u4ef62\u4f9d\u8d56\u4e8e\u6587\u4ef61\u800c\u5b58\u5728\uff0c\u5982\u679c\u5220\u9664\u4e86\u6587\u4ef61\uff0c\u6253\u5f00\u6587\u4ef62\u5c31\u4f1a\u62a5\u9519\uff1a\"No such file or directory\"\u3002\u8fd9\u662f\u8f6f\u94fe\u63a5\u4e0e\u786c\u94fe\u63a5\u6700\u5927\u7684\u4e0d\u540c\uff1a\u6587\u4ef62\u6307\u5411\u6587\u4ef61\u7684\u8def\u5f84\uff0c\u800c\u4e0d\u662f\u6587\u4ef61\u7684inode\u53f7\u7801\uff0c\u6587\u4ef61\u7684inode\"\u94fe\u63a5\u6570\"\u4e0d\u4f1a\u56e0\u6b64\u53d1\u751f\u53d8\u5316\u3002<\/code><\/pre>\n<\/li>\n<\/ul>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u8f6f\u8fde\u63a5.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  data-original=\"https:\/\/egonlin.com\/wp-content\/uploads\/2021\/07\/\u8f6f\u8fde\u63a5.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<p><strong>\u786c\u94fe\u63a5\u77e5\u8bc6\u70b9\u63d0\u70bc<\/strong><\/p>\n<pre><code class=\"language-python\">0.\u5bf9\u786c\u94fe\u6587\u4ef6\u5185\u5bb9\u8fdb\u884c\u4fee\u6539\uff0c\u4f1a\u5f71\u54cd\u5230\u6240\u6709\u6587\u4ef6\u540d\uff1b\n\n1.\u786c\u94fe\u63a5\u6587\u4ef6\u4e0e\u6e90\u6587\u4ef6\u5177\u6709\u76f8\u540cinode\u7684\u4e0d\u540c\u6587\u4ef6\u540d\uff1a\u4e00\u4e2a\u6587\u4ef6\u53ea\u80fd\u6709\u4e00\u4e2ainode\u53f7\uff0c\u4f46\u591a\u4e2a\u6587\u4ef6\u7684inode\u53f7\u53ef\u4ee5\u76f8\u540c\n\n2.\u5220\u9664\u786c\u94fe\u63a5\u6216\u8005\u539f\u6587\u4ef6\u4e4b\u4e00\uff0c\u4e0d\u5f71\u54cd\u53e6\u4e00\u4e2a\u6587\u4ef6\u540d\u7684\u8bbf\u95ee\uff0c\u9664\u975e\u6240\u6709\u7684\u90fd\u5220\u9664\u6389\uff0c\u6240\u4ee5\u786c\u8fde\u63a5\u7684\u4f5c\u7528\u662f\u5141\u8bb8\u4e00\u4e2a\u6587\u4ef6\u62e5\u6709\u591a\u4e2a\u6709\u6548\u8def\u5f84\u540d\uff0c\u8fd9\u6837\u7528\u6237\u5c31\u53ef\u4ee5\u5efa\u7acb\u786c\u8fde\u63a5\u5230\u91cd\u8981\u6587\u4ef6\uff0c\u4ee5\u9632\u6b62\u201c\u8bef\u5220\u201d\u7684\u529f\u80fd\u3002\n\n3.\u5220\u9664\u6240\u6709\u786c\u94fe\u63a5\uff0c\u6570\u636e\u4f1a\u5728\u88ab\u78c1\u76d8\u68c0\u67e5\u6216\u8005\u65b0\u6570\u636e\u5199\u5165\u65f6\u5019\u5220\u9664\u56de\u6536\u3002\n\n4.\u901a\u8fc7ln [\u539f\u6587\u4ef6] [\u76ee\u6807\u6587\u4ef6]\u8bbe\u7f6e\u786c\u94fe\u63a5\n\n5.\u901a\u8fc7rm \u2013f \u5220\u9664\u786c\u94fe\u63a5\n\n6.\u76ee\u5f55\u4e0d\u53ef\u521b\u5efa\u786c\u94fe\u63a5\uff0c\u5e76\u4e14\u786c\u94fe\u63a5\u65e0\u6cd5\u8de8\u533a\n\n# \u793a\u4f8b\n[root@localhost ~]# touch small_egon.txt\n[root@localhost ~]# ln small_egon.txt big_egon.txt\n\n[root@localhost ~]# ls -i small_egon.txt \n17696460 small_egon.txt\n[root@localhost ~]# ls -i big_egon.txt \n17696460 big_egon.txt\n\n[root@localhost ~]# ll small_egon.txt  # \u4e24\u4e2a\u786c\u94fe\u63a5\u6587\u4ef6\u7684\u786c\u94fe\u63a5\u6570\u5747\u4e3a2\n-rw-r--r-- 2 root root 0 12\u6708 16 17:05 small_egon.txt\n[root@localhost ~]# ll big_egon.txt  # \u4e24\u4e2a\u786c\u94fe\u63a5\u6587\u4ef6\u7684\u786c\u94fe\u63a5\u6570\u5747\u4e3a2\n-rw-r--r-- 2 root root 0 12\u6708 16 17:05 big_egon.txt<\/code><\/pre>\n<p><strong>\u8f6f\u94fe\u63a5\u77e5\u8bc6\u63d0\u70bc<\/strong><\/p>\n<pre><code class=\"language-python\">#0. \u5bf9\u8f6f\u94fe\u7684\u6e90\u6587\u4ef6\u6216\u76ee\u6807\u6587\u4ef6\u5185\u5bb9\u8fdb\u884c\u4fee\u6539\uff0c\u4f1a\u5f71\u54cd\u5230\u6240\u6709\u6587\u4ef6\u540d\uff1b\n\n#1. \u8f6f\u94fe\u63a5\u6587\u4ef6\u4e0e\u6e90\u6587\u4ef6\u5177\u6709\u4e0d\u540c\u7684inode\u53f7\n\n#2. \u5220\u9664\u8f6f\u8fde\u63a5\u6587\u4ef6\u7684\u6e90\u6587\u4ef6\uff0c\u8f6f\u94fe\u63a5\u6587\u4ef6\u5c06\u65e0\u6cd5\u4f7f\u7528\uff0c\u8f6f\u94fe\u63a5\u4f5c\u7528\n- 1.\u8f6f\u4ef6\u5347\u7ea7 \n- 2.\u4f01\u4e1a\u4ee3\u7801\u53d1\u5e03 \n- 3.\u4e0d\u65b9\u4fbf\u76ee\u5f55\u79fb\u52a8\n\n#3. \u5220\u9664\u6e90\u6587\u4ef6\u540e\uff0c\u8f6f\u8fde\u63a5\u6587\u4ef6\u65e0\u6548\uff0c\u5e94\u8be5\u4e5f\u4e00\u8d77\u5220\u9664\u6389\uff0c\u4ee5\u4fbf\u56de\u6536\n\n#4. \u6267\u884cln \u2013s [\u539f\u6587\u4ef6] [\u76ee\u6807\u6587\u4ef6]\u521b\u5efa\u8f6f\u94fe\u63a5\n\n#5. rm \u2013f \u5220\u9664\u8f6f\u94fe\u63a5\n\n#6\u3001\u53ef\u4ee5\u5bf9\u76ee\u5f55\u521b\u5efa\u8f6f\u94fe\u63a5\uff0c\u5e76\u4e14\u8f6f\u8fde\u63a5\u53ef\u4ee5\u8de8\u5206\u533a\n\n[root@localhost ~]# touch 1.txt\n[root@localhost ~]# ln -s 1.txt 2.txt\n[root@localhost ~]# ls -i 1.txt \n17696462 1.txt\n[root@localhost ~]# ls -i 2.txt \n17696463 2.txt\n[root@localhost ~]# \n[root@localhost ~]# ll 1.txt  # \u4e24\u4e2a\u8f6f\u94fe\u63a5\u6587\u4ef6\u7684\u786c\u94fe\u63a5\u6570\u5747\u4e3a1\n-rw-r--r-- 1 root root 0 12\u6708 16 17:26 1.txt\n[root@localhost ~]# ll 2.txt  # \u4e24\u4e2a\u8f6f\u94fe\u63a5\u6587\u4ef6\u7684\u786c\u94fe\u63a5\u6570\u5747\u4e3a1\nlrwxrwxrwx 1 root root 5 12\u6708 16 17:26 2.txt -&gt; 1.txt\n[root@localhost ~]# \n\n[root@localhost ~]# rm -rf 1.txt  # \u5220\u63891.txt\uff0c\u4f1a\u53d1\u73b02.txt\u4e0d\u53ef\u7528\n[root@localhost ~]# ll 2.txt \nlrwxrwxrwx 1 root root 5 12\u6708 16 17:26 2.txt -&gt; 1.txt\n[root@localhost ~]# \n\n[root@localhost ~]# mkdir \/dir1\n[root@localhost ~]# ln \/dir1 \/dir2\nln: &quot;\/dir1&quot;: \u4e0d\u5141\u8bb8\u5c06\u786c\u94fe\u63a5\u6307\u5411\u76ee\u5f55\n[root@localhost ~]# \n[root@localhost ~]# ln -s \/dir1\/ \/dir2\n[root@localhost ~]# <\/code><\/pre>\n<h3>7.6 \u5b9e\u6218\u5e94\u7528<\/h3>\n<p><strong>\u78c1\u76d8\u6709\u7a7a\u95f4\u4f46\u521b\u5efa\u4e0d\u4e86\u6587\u4ef6<\/strong><\/p>\n<p>\u5b9e\u6218\u573a\u666f\uff1a\u5728\u4e00\u53f0\u914d\u7f6e\u8f83\u4f4e\u7684Linux\u670d\u52a1\u5668\uff08\u5185\u5b58\u3001\u786c\u76d8\u6bd4\u8f83\u5c0f\uff09\u7684\/data\u5206\u533a\u5185\u521b\u5efa\u6587\u4ef6\u65f6\uff0c\u7cfb\u7edf\u63d0\u793a\u78c1\u76d8\u7a7a\u95f4\u4e0d\u8db3\uff0c\u7528df -h\u547d\u4ee4\u67e5\u770b\u4e86\u4e00\u4e0b\u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\uff0c\u53d1\u73b0\/data\u5206\u533a\u53ea\u4f7f\u7528\u4e8680%\uff0c\u8fd8\u67091.9G\u7684\u5269\u4f59\u7a7a\u95f4\uff0c\u4f46\u662f\u65e0\u6cd5\u521b\u5efa\u65b0\u7684\u6587\u4ef6\u3002\u5f53\u65f6\u4f7f\u7528\u7684\u662froot\u7528\u6237\u3002\u670d\u52a1\u5668\u6ca1\u6709\u88ab\u9ed1\u3002<\/p>\n<pre><code>[root@xxx ~]# df -h\n\u6587\u4ef6\u7cfb\u7edf  \u5bb9\u91cf\u5df2\u7528  \u53ef\u7528   \u5df2\u7528%  \u6302\u8f7d\u70b9\n\/dev\/sda310G   8.0G  1.9G   80%\/<\/code><\/pre>\n<p>\u5e38\u8bc6\uff1a \u53ea\u8981\u6743\u9650\u591f\uff0c\u78c1\u76d8\u4e0a\u6709\u7a7a\u95f4\u4e00\u5b9a\u53ef\u4ee5\u521b\u5efa\u6587\u4ef6\u3002 \u8fd9\u4e2a\u662f\u9519\u7684\u3002<\/p>\n<p>\u6392\u67e5\uff1a<\/p>\n<pre><code>[root@xxx ~]# df -i  \n\u6587\u4ef6\u7cfb\u7edf Inode \u5df2\u7528(I) \u53ef\u7528(I) \u5df2\u7528(I)%   \u6302\u8f7d\u70b9\n\/dev\/sda3  5242880   52428800  100%\/<\/code><\/pre>\n<p>\u540e\u6765\u7528df -i\u67e5\u770b\u4e86\u4e00\u4e0b\/data\u6240\u5728\u7684\u5206\u533a\u7684\u7d22\u5f15\u8282\u70b9(inode)\uff0c\u53d1\u73b0\u5df2\u7ecf\u7528\u6ee1(IUsed=100%)\uff0c\u5bfc\u81f4\u7cfb\u7edf\u65e0\u6cd5\u521b\u5efa\u65b0\u76ee\u5f55\u548c\u6587\u4ef6\u3002<\/p>\n<p>\u67e5\u627e\u539f\u56e0\uff1a<br \/>\n\u3000\u3000\/data\/cache\u76ee\u5f55\u4e2d\u5b58\u5728\u6570\u91cf\u975e\u5e38\u591a\u7684\u5c0f\u5b57\u8282\u7f13\u5b58\u6587\u4ef6\uff0c\u5360\u7528\u7684Block\u4e0d\u591a\uff0c\u4f46\u662f\u5360\u7528\u4e86\u5927\u91cf\u7684inode\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u68481\uff1a\u5220\u9664\/data\/cache\u76ee\u5f55\u4e2d\u7684\u90e8\u5206\u6587\u4ef6\uff0c\u91ca\u653e\u51fa\/data\u5206\u533a\u7684\u4e00\u90e8\u5206inode\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u68482 : \u5728\/data\u5907\u4efd\u597d\u4e00\u4e9b\u6587\u4ef6\uff0c\u7136\u540e\u5220\u9664\u8fd9\u4e9b\u6587\u4ef6\uff0c\u91ca\u653e\u4e00\u4e9binode\uff0c\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\/data\/cache2\u3002\u5728cache2\u4e0b\u6302\u8f7d\u4e00\u4e2a\u65b0\u5206\u533a\uff1a sda4 \uff0c\u4e0b\u6b21\u5199\u6570\u636e\u9700\u8981\u5199\u5230\u65b0\u5206\u533acache2\u76ee\u5f55\u4e0b\u3002<\/p>\n<pre><code class=\"language-python\">[root@egon ~]# mkfs.xfs \/dev\/sdb \nmeta-data=\/dev\/sdb               isize=512    agcount=4, agsize=1310720 blks\n         =                       sectsz=512   attr=2, projid32bit=1\n         =                       crc=1        finobt=0, sparse=0\ndata     =                       bsize=4096   blocks=5242880, imaxpct=25\n         =                       sunit=0      swidth=0 blks\nnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1\nlog      =internal log           bsize=4096   blocks=2560, version=2\n         =                       sectsz=512   sunit=0 blks, lazy-count=1\nrealtime =none                   extsz=4096   blocks=0, rtextents=0\n[root@egon ~]# \n[root@egon ~]# mkdir \/data\/cache2\n[root@egon ~]# mount \/dev\/sdb \/data\/cache2\/<\/code><\/pre>\n<p>inode\u5206\u533a\u5b8c\u540e\uff0c\u4e0d\u53ef\u4ee5\u589e\u52a0inode\u6570\u91cf\uff0c\u6539\u53d8inode\u5927\u5c0f<\/p>\n<p><strong>\u5176\u4ed6\u573a\u666f<\/strong><\/p>\n<p>1.\u5927\u91cf\u7684\u5c0f\u6587\u4ef6\u95ee\u9898\uff1a\u53ef\u80fd\u4f1a\u4f7finode\u8017\u5c3d\uff0c\u4f7f\u5f97\u6587\u4ef6\u6587\u6cd5\u521b\u5efa\u3002\uff08\u78c1\u76d8\u5229\u7528\u7387\u4f4e\uff09&#8212;&gt;\u5bf9\u4e8e\u5c0f\u6587\u4ef6\u6bd4\u8f83\u591a\u7684\u573a\u666f\uff0c\u5c06block\u5212\u5206\u5c0f\u4e00\u70b9\u3002<br \/>\n2.\u5927\u6587\u4ef6\u95ee\u9898\uff1a\u4e00\u4e2a\u6587\u4ef6\u5360\u7528\u591a\u4e2ablock\uff0c\u4f7f\u5f97\u6587\u4ef6\u8bfb\u5199\u901f\u7387\u6162\u3002&#8212;-&gt;\u5c06block\u5212\u5206\u5927\u4e00\u70b9\u3002<br \/>\n3.ext\u6587\u4ef6\u7cfb\u7edf\u2014\u2014xfs\u6587\u4ef6\u7cfb\u7edf<\/p>\n<p><strong>\u4f01\u4e1a\u9762\u8bd5\u9898\uff1a\u8bf7\u63cf\u8ff0Linux\u4e2d\u8f6f\u94fe\u63a5\u548c\u786c\u94fe\u63a5\u7684\u533a\u522b<\/strong><\/p>\n<p>1.\u4ece\u5b9a\u4e49\uff1alinux\u7cfb\u7edf\u4e2d\uff0c\u94fe\u63a5\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u88ab\u79f0\u4e3a\u8f6f\u94fe\u63a5\uff0c\u7c7b\u4f3c\u4e8e\u5feb\u6377\u65b9\u5f0f\uff0c\u5b58\u653e\u6307\u5411\u539f\u6587\u4ef6inode\u7684\u4fe1\u606f\uff0c\u4e0e\u539f\u6587\u4ef6inode\u4e0d\u540c\u3002\u4e00\u79cd\u662f\u786c\u94fe\u63a5\uff0c\u4e0e\u539f\u6587\u4ef6\u6709\u76f8\u540c\u7684inode\uff0c\u53ef\u4ee5\u6307\u5411\u6570\u636eblock\u3002<\/p>\n<p>2.\u4ece\u521b\u5efa\u65b9\u5f0f\uff1a\u786c\u94fe\u63a5\u547d\u4ee4 ln [\u539f\u6587\u4ef6] [\u76ee\u6807\u6587\u4ef6]\uff0c\u8f6f\u94fe\u63a5\u547d\u4ee4ln \u2013s [\u539f\u6587\u4ef6] [\u76ee\u6807\u6587\u4ef6]<\/p>\n<p>3.\u4ece\u521b\u5efa\u5bf9\u8c61\uff1aln\u547d\u4ee4\u4e0d\u80fd\u5bf9\u76ee\u5f55\u521b\u5efa\u786c\u94fe\u63a5\uff0c\u4f46\u662f\u53ef\u4ee5\u5bf9\u76ee\u5f55\u521b\u5efa\u8f6f\u94fe\u63a5\u3002\u56e0\u4e3a\u8f6f\u94fe\u63a5\u53ef\u4ee5\u8de8\u8d8a\u6587\u4ef6\u7cfb\u7edf\uff0c\u786c\u94fe\u63a5\u5219\u4e0d\u80fd\u3002\u5bf9\u76ee\u5f55\u548c\u4e3a\u5ba2\u6237\u521b\u5efa\u7684\u6587\u4ef6\u8f6f\u94fe\u63a5\u7ecf\u5e38\u7528\u5230\u3002<\/p>\n<p>4.\u5220\u9664\u8f6f\u94fe\u63a5\u6587\u4ef6\uff0c\u5bf9\u786c\u94fe\u63a5\u548c\u539f\u6587\u4ef6\u65e0\u5f71\u54cd\u3002<\/p>\n<p>5.\u5220\u9664\u6587\u4ef6\u786c\u94fe\u63a5\uff0c\u5bf9\u539f\u6587\u4ef6\u53ca\u8f6f\u94fe\u63a5\u6587\u4ef6\u65e0\u5f71\u54cd<\/p>\n<p>6.\u5220\u9664\u539f\u6587\u4ef6\uff0c\u5bf9\u786c\u94fe\u63a5\u8bfb\u53d6\u6570\u636e\u65e0\u5f71\u54cd\uff0c\u8f6f\u94fe\u63a5\u5219\u5931\u6548\u3002\u4f1a\u51fa\u73b0\u7ea2\u5e95\u767d\u5b57\u72b6\u3002<\/p>\n<p>7.\u540c\u65f6\u5220\u9664\u539f\u6587\u4ef6\u548c\u786c\u94fe\u63a5\uff0c\u539f\u6587\u4ef6\u624d\u4f1a\u88ab\u771f\u6b63\u5220\u9664<\/p>\n<p>8.\u5f88\u591a\u786c\u4ef6\u8bbe\u5907\u4e2d\u7684\u5feb\u7167\u539f\u7406\uff0c\u7c7b\u4f3c\u4e8e\u786c\u94fe\u63a5\u539f\u7406<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u4ef6\u7ba1\u7406\u4e4b\uff08\u9ad8\u7ea7\uff09 \u4e00 \u6587\u672c\u5904\u7406\u4e09\u5251\u5ba2\u547d\u4ee4\u521d\u63a2 \u4e09\u5251\u5ba2\u547d\u4ee4\u6211\u4eec\u5c06\u5728shell\u7f16\u7a0b\u91cc\u6df1\u5165\u8bb2\u89e3\uff0c\u6b64\u5904\u5148\u5b66\u4f1a\u6700\u57fa\u672c\u7684 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":187,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[37],"tags":[21,19,35,22,20],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/184"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184"}],"version-history":[{"count":6,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":8737,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions\/8737"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/media\/187"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}