df du命令

來源:互聯網
上載者:User

標籤:df   du   

df 命令

 df查看已掛載磁碟的總容量、使用容量、剩餘容量等。可以不加任何參數,預設按k為單位顯示。

[[email protected] ~]# df

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/sda3       18244476 1603980  15707072  10% /

tmpfs             506228       0    506228   0% /dev/shm

/dev/sda1         194241   27180    156821  15% /boot

df常用選項有 -i  , -h  , -k  , -m


-i 查看inodes使用狀況

[[email protected] ~]# df -i

Filesystem      Inodes IUsed   IFree IUse% Mounted on

/dev/sda3      1166880 37974 1128906    4% /

tmpfs           126557     1  126556    1% /dev/shm

/dev/sda1        51200    38   51162    1% /boot

-h 使用合適的單位顯示,例如 G

[[email protected] ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        18G  1.6G   15G  10% /

tmpfs           495M     0  495M   0% /dev/shm

/dev/sda1       190M   27M  154M  15% /boot

-k , -m 分別以K和M為單位顯示

[[email protected] ~]# df -k

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/sda3       18244476 1603980  15707072  10% /

tmpfs             506228       0    506228   0% /dev/shm

/dev/sda1         194241   27180    156821  15% /boot

[[email protected] ~]# df -m

Filesystem     1M-blocks  Used Available Use% Mounted on

/dev/sda3          17817  1567     15339  10% /

tmpfs                495     0       495   0% /dev/shm

/dev/sda1            190    27       154  15% /boot

各列所代表的含義為:第一列是分區的名字,第二列為該分區總共的容量,第三列為已經使用了多少,第四列為還剩下多少,第五列為已經使用的百分比(如若達到90%以上,就應該關注了,分區滿了會引起系統崩潰),最後一列為掛載點,/dev/shm 為記憶體掛載點,如果想把檔案放到記憶體裡,就可以放到/dev/shm/ 目錄下。

du 命令


du 用來查看某個目錄或檔案所佔空間大小。文法: du [-abckmsh] [檔案或者目錄名] 常用的參數有:


 -a :全部檔案與目錄大小都列出來。如果不加選項和參數只列出目錄(包含子目錄)大小。

[[email protected] ~]# du dirb

4       dirb/dirc

8       dirb

[[email protected] ~]# du -a dirb

0       dirb/filee

4       dirb/dirc

8       dirb

如果du不指定單位的話,預設顯示單位為K。

-b :列出的值以bytes為單位輸出。

-k :以KB為單位輸出,和預設不加任何選項的輸出值是一樣的。

-m :以MB為單位輸出。

-h :系統自動調節單位,例如檔案大小可能就幾K,那麼就以K為單位顯示,如果大到幾G,就以G為單位顯示。

[[email protected] ~]# du -b /etc/passwd

1023    /etc/passwd

[[email protected] ~]# du -k /etc/passwd

4       /etc/passwd

[[email protected] ~]# du -m /etc/passwd

1       /etc/passwd

[[email protected] ~]# du -h /etc/passwd

4.0K    /etc/passwd

-c 選項為最後加總

[[email protected] ~]# du -c dirb

4       dirb/dirc

8       dirb

8       總用量

[[email protected] ~]# du dirb

4       dirb/dirc

8       dirb

-s 只列出總和

[[email protected] ~]# du -s dirb

8       dirb

單單查看某一目錄大小屬性,-sh搭配使用最好,du -sh filename


df du命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.