真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

獲取Linux系統(tǒng)中目錄文件大小的方法

你應(yīng)該已經(jīng)注意到,在?Linux?中使用 ls?命令?列出的目錄內(nèi)容中,目錄的大小僅顯示 4KB。這個(gè)大小正確嗎?如果不正確,那它代表什么,又該如何獲取 Linux 中的目錄或文件夾大?。窟@是一個(gè)默認(rèn)的大小,是用來(lái)存儲(chǔ)磁盤(pán)上存儲(chǔ)目錄的元數(shù)據(jù)的大小。

Linux 上有一些應(yīng)用程序可以 獲取目錄的實(shí)際大小。其中,磁盤(pán)使用率(du)命令已被 Linux 管理員廣泛使用。

成都創(chuàng)新互聯(lián)公司專注于平塘網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供平塘營(yíng)銷型網(wǎng)站建設(shè),平塘網(wǎng)站制作、平塘網(wǎng)頁(yè)設(shè)計(jì)、平塘網(wǎng)站官網(wǎng)定制、微信小程序開(kāi)發(fā)服務(wù),打造平塘網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供平塘網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

我將向您展示如何使用各種選項(xiàng)獲取文件夾大小。

什么是 du 命令?

du 命令 表示 磁盤(pán)使用率(Disk Usage)。這是一個(gè)標(biāo)準(zhǔn)的 Unix 程序,用于估計(jì)當(dāng)前工作目錄中的文件空間使用情況。

它使用遞歸方式總結(jié)磁盤(pán)使用情況,以獲取目錄及其子目錄的大小。

如同我說(shuō)的那樣, 使用 ls 命令時(shí),目錄大小僅顯示 4KB。參見(jiàn)下面的輸出。

$?ls?-lh?|?grep?^d
drwxr-xr-x??3?daygeek?daygeek?4.0K?Aug??2?13:57?Bank_Details
drwxr-xr-x??2?daygeek?daygeek?4.0K?Mar?15??2019?daygeek
drwxr-xr-x??6?daygeek?daygeek?4.0K?Feb?16??2019?drive-2daygeek
drwxr-xr-x?13?daygeek?daygeek?4.0K?Jan??6??2019?drive-mageshm
drwxr-xr-x?15?daygeek?daygeek?4.0K?Sep?29?21:32?Thanu_Photos

1) 在 Linux 上如何只獲取父目錄的大小

使用以下 du 命令格式獲取給定目錄的總大小。在該示例中,我們將得到 /home/daygeek/Documents 目錄的總大小。

$?du?-hs?/home/daygeek/Documents

$?du?-h?--max-depth=0?/home/daygeek/Documents/
20G????/home/daygeek/Documents

詳細(xì)說(shuō)明:

du – 這是一個(gè)命令

-h – 以易讀的格式顯示大小 (例如 1K 234M 2G)

-s – 僅顯示每個(gè)參數(shù)的總數(shù)

--max-depth=N – 目錄的打印深度

2) 在 Linux 上如何獲取每個(gè)目錄的大小

使用以下 du 命令格式獲取每個(gè)目錄(包括子目錄)的總大小。

在該示例中,我們將獲得每個(gè) /home/daygeek/Documents 目錄及其子目錄的總大小。

$?du?-h?/home/daygeek/Documents/?|?sort?-rh?|?head?-20
20G????/home/daygeek/Documents/
9.6G????/home/daygeek/Documents/drive-2daygeek
6.3G????/home/daygeek/Documents/Thanu_Photos
5.3G????/home/daygeek/Documents/Thanu_Photos/Camera
5.3G????/home/daygeek/Documents/drive-2daygeek/Thanu-videos
3.2G????/home/daygeek/Documents/drive-mageshm
2.3G????/home/daygeek/Documents/drive-2daygeek/Thanu-Photos
2.2G????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month
916M????/home/daygeek/Documents/drive-mageshm/Tanisha
454M????/home/daygeek/Documents/drive-mageshm/2g-backup
415M????/home/daygeek/Documents/Thanu_Photos/WhatsApp?Video
300M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Jan-2017
288M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Oct-2017
226M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Sep-2017
219M????/home/daygeek/Documents/Thanu_Photos/WhatsApp?Documents
213M????/home/daygeek/Documents/drive-mageshm/photos
163M????/home/daygeek/Documents/Thanu_Photos/WhatsApp?Video/Sent
161M????/home/daygeek/Documents/Thanu_Photos/WhatsApp?Images
154M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/June-2017
150M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Nov-2016

3) 在 Linux 上如何獲取每個(gè)目錄的摘要

使用如下 du 命令格式僅獲取每個(gè)目錄的摘要。

$?du?-hs?/home/daygeek/Documents/*?|?sort?-rh?|?head?-10
9.6G????/home/daygeek/Documents/drive-2daygeek
6.3G????/home/daygeek/Documents/Thanu_Photos
3.2G????/home/daygeek/Documents/drive-mageshm
756K????/home/daygeek/Documents/Bank_Details
272K????/home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-TouchInterface1.png
172K????/home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-NightLight.png
164K????/home/daygeek/Documents/ConfigServer?Security?and?Firewall?(csf)?Cheat?Sheet.pdf
132K????/home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-Todo.png
112K????/home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-ZorinAutoTheme.png
96K????/home/daygeek/Documents/distro-info.xlsx

4) 在 Linux 上如何獲取每個(gè)目錄的不含子目錄的大小

使用如下 du 命令格式來(lái)展示每個(gè)目錄的總大小,不包括子目錄。

$?du?-hS?/home/daygeek/Documents/?|?sort?-rh?|?head?-20
5.3G????/home/daygeek/Documents/Thanu_Photos/Camera
5.3G????/home/daygeek/Documents/drive-2daygeek/Thanu-videos
2.3G????/home/daygeek/Documents/drive-2daygeek/Thanu-Photos
1.5G????/home/daygeek/Documents/drive-mageshm
831M????/home/daygeek/Documents/drive-mageshm/Tanisha
454M????/home/daygeek/Documents/drive-mageshm/2g-backup
300M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Jan-2017
288M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Oct-2017
253M????/home/daygeek/Documents/Thanu_Photos/WhatsApp?Video
226M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Sep-2017
219M????/home/daygeek/Documents/Thanu_Photos/WhatsApp?Documents
213M????/home/daygeek/Documents/drive-mageshm/photos
163M????/home/daygeek/Documents/Thanu_Photos/WhatsApp?Video/Sent
154M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/June-2017
150M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Nov-2016
127M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Dec-2016
100M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Oct-2016
94M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Nov-2017
92M????/home/daygeek/Documents/Thanu_Photos/WhatsApp?Images
90M????/home/daygeek/Documents/drive-2daygeek/Thanu-photos-by-month/Dec-2017

5) 在 Linux 上如何僅獲取一級(jí)子目錄的大小

如果要獲取 Linux 上給定目錄的一級(jí)子目錄(包括其子目錄)的大小,請(qǐng)使用以下命令格式。

$?du?-h?--max-depth=1?/home/daygeek/Documents/
3.2G????/home/daygeek/Documents/drive-mageshm
4.0K????/home/daygeek/Documents/daygeek
756K????/home/daygeek/Documents/Bank_Details
9.6G????/home/daygeek/Documents/drive-2daygeek
6.3G????/home/daygeek/Documents/Thanu_Photos
20G????/home/daygeek/Documents/

6) 如何在 du 命令輸出中獲得總計(jì)

如果要在 du 命令輸出中獲得總計(jì),請(qǐng)使用以下 du 命令格式。

$?du?-hsc?/home/daygeek/Documents/*?|?sort?-rh?|?head?-10
20G????total
9.6G????/home/daygeek/Documents/drive-2daygeek
6.3G????/home/daygeek/Documents/Thanu_Photos
3.2G????/home/daygeek/Documents/drive-mageshm
756K????/home/daygeek/Documents/Bank_Details
272K????/home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-TouchInterface1.png
172K????/home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-NightLight.png
164K????/home/daygeek/Documents/ConfigServer?Security?and?Firewall?(csf)?Cheat?Sheet.pdf
132K????/home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-Todo.png
112K????/home/daygeek/Documents/user-friendly-zorin-os-15-has-been-released-ZorinAutoTheme.png

名稱欄目:獲取Linux系統(tǒng)中目錄文件大小的方法
網(wǎng)頁(yè)路徑:http://weahome.cn/article/isgids.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部