上海校区切换校区
图片
du 及 df 命令的使用(附带示例)     <p><span style="color:#999999;font-family:Optima-Regular, PingFangTC-light;line-height:19.2px;background-color:#FFFFFF;">du 和 df 命令都是 Linux 系统的重要工具,来显示 Linux 文件系统的磁盘使用情况。</span></p><p><span style="color:#999999;font-family:Optima-Regular, PingFangTC-light;line-height:19.2px;background-color:#FFFFFF;"><p class="" style="font-family:Optima-Regular, PingFangTC-light;color:#FFFFFF;font-size:1.4em;background-color:#3F51B5;">du 命令</p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">du(disk usage 的简称)是用于查找文件和目录的磁盘使用情况的命令。du&nbsp;命令在与各种选项一起使用时能以多种格式提供结果。</p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">下面是一些例子:</p><p class="" style="font-family:Optima-Regular, PingFangTC-light;color:#FFFFFF;font-size:1.2em;background-color:#3F51B5;">1、 得到一个目录下所有子目录的磁盘使用概况</p> <pre class=""><ol class="list-paddingleft-2"><li><p><span class="" style="color:#B8FFB8;">$ </span><span class="" style="color:#E28964;">du</span><span class="" style="color:#B8FFB8;"> </span><span class="" style="color:#B8FFB8;">/</span><span class="" style="color:#B8FFB8;">home</span></p></li></ol></pre> <p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><img src="http://115.29.210.249/tggPic/content/2018-03/1521509290068.jpg" data-ke-src="http://115.29.210.249/tggPic/content/2018-03/1521509290068.jpg" alt=""><br></p><p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><em>du command</em></p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">该命令的输出将显示&nbsp;/home&nbsp;中的所有文件和目录以及显示块大小。</p><p class="" style="font-family:Optima-Regular, PingFangTC-light;color:#FFFFFF;font-size:1.2em;background-color:#3F51B5;">2、 以人类可读格式也就是 kb、mb 等显示文件/目录大小</p> <pre class=""><ol class="list-paddingleft-2"><li><p><span class="" style="color:#B8FFB8;">$ </span><span class="" style="color:#E28964;">du</span><span class="" style="color:#B8FFB8;"> </span><span class="" style="color:#B8FFB8;">-</span><span class="" style="color:#B8FFB8;">h </span><span class="" style="color:#B8FFB8;">/</span><span class="" style="color:#B8FFB8;">home</span></p></li></ol></pre> <p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><img src="http://115.29.210.249/tggPic/content/2018-03/1521509301479.jpg" data-ke-src="http://115.29.210.249/tggPic/content/2018-03/1521509301479.jpg" alt=""><br></p><p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><em>du command</em></p><p class="" style="font-family:Optima-Regular, PingFangTC-light;color:#FFFFFF;font-size:1.2em;background-color:#3F51B5;">3、 目录的总磁盘大小</p> <pre class=""><ol class="list-paddingleft-2"><li><p><span class="" style="color:#B8FFB8;">$ </span><span class="" style="color:#E28964;">du</span><span class="" style="color:#B8FFB8;"> </span><span class="" style="color:#B8FFB8;">-</span><span class="" style="color:#B8FFB8;">s </span><span class="" style="color:#B8FFB8;">/</span><span class="" style="color:#B8FFB8;">home</span></p></li></ol></pre> <p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><img src="http://115.29.210.249/tggPic/content/2018-03/1521509311385.jpg" data-ke-src="http://115.29.210.249/tggPic/content/2018-03/1521509311385.jpg" alt=""><br></p><p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><em>du command</em></p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">它是&nbsp;/home&nbsp;目录的总大小</p><p class="" style="font-family:Optima-Regular, PingFangTC-light;color:#FFFFFF;font-size:1.4em;background-color:#3F51B5;">df 命令</p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">df(disk filesystem 的简称)用于显示 Linux 系统的磁盘利用率。(LCTT 译注:df&nbsp;可能应该是 disk free 的简称。)</p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">下面是一些例子。</p><p class="" style="font-family:Optima-Regular, PingFangTC-light;color:#FFFFFF;font-size:1.2em;background-color:#3F51B5;">1、 显示设备名称、总块数、总磁盘空间、已用磁盘空间、可用磁盘空间和文件系统上的挂载点。</p> <pre class=""><ol class="list-paddingleft-2"><li><p><span class="" style="color:#B8FFB8;">$ </span><span class="" style="color:#E28964;">df</span></p></li></ol></pre> <p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><img src="http://115.29.210.249/tggPic/content/2018-03/1521509323256.jpg" data-ke-src="http://115.29.210.249/tggPic/content/2018-03/1521509323256.jpg" alt=""><br></p><p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><em>df command</em></p><p class="" style="font-family:Optima-Regular, PingFangTC-light;color:#FFFFFF;font-size:1.2em;background-color:#3F51B5;">2、 人类可读格式的信息</p> <pre class=""><ol class="list-paddingleft-2"><li><p><span class="" style="color:#B8FFB8;">$ </span><span class="" style="color:#E28964;">df</span><span class="" style="color:#B8FFB8;"> </span><span class="" style="color:#B8FFB8;">-</span><span class="" style="color:#B8FFB8;">h</span></p></li></ol></pre> <p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><img src="http://115.29.210.249/tggPic/content/2018-03/1521509333001.jpg" data-ke-src="http://115.29.210.249/tggPic/content/2018-03/1521509333001.jpg" alt=""><br></p><p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><em>df command</em></p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">上面的命令以人类可读格式显示信息。</p><p class="" style="font-family:Optima-Regular, PingFangTC-light;color:#FFFFFF;font-size:1.2em;background-color:#3F51B5;">3、 显示特定分区的信息</p> <pre class=""><ol class="list-paddingleft-2"><li><p><span class="" style="color:#B8FFB8;">$ </span><span class="" style="color:#E28964;">df</span><span class="" style="color:#B8FFB8;"> </span><span class="" style="color:#B8FFB8;">-</span><span class="" style="color:#B8FFB8;">hT </span><span class="" style="color:#B8FFB8;">/</span><span class="" style="color:#B8FFB8;">etc</span></p></li></ol></pre> <p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><img src="http://115.29.210.249/tggPic/content/2018-03/1521509351248.jpg" data-ke-src="http://115.29.210.249/tggPic/content/2018-03/1521509351248.jpg" alt=""><br></p><p class="" style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;text-align:center;"><em>df command</em></p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">-hT&nbsp;加上目标目录将以可读格式显示&nbsp;/etc&nbsp;的信息。</p><p style="color:#3E3E3E;font-family:Optima-Regular, PingFangTC-light;font-size:14px;">虽然&nbsp;du&nbsp;和&nbsp;df&nbsp;命令有更多选项,但是这些例子可以让你初步了解。如果在这里找不到你要找的东西,那么你可以参考有关命令的 man 页面。</p>​<br></span></p>
在线咨询 ×

您好,请问有什么可以帮您?我们将竭诚提供最优质服务!