關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • Linux 顯示目錄使用情況

    Posted on December 8th, 2007 Sam Tang No comments

    在 Linux 下要檢查某個目錄的使用情況,那就是目錄內所有檔案及目錄的使用量,可以用 「du」 指令,它的原意為 「disk usage」。

    如果想顯示目錄下的所有檔案及目錄,可以用 「-a」 或 「–all」 選擇;
    要增加可讀性,即是以 KB, MB, GB 來顯示容量,可以用 「-h」 或 「–human-readable」

    但如果一個目錄內的檔案有很多,在輸入 「du -ah dirname」 後所顯示的資訊十分多,這可以改用 「du -sh dirname」 來取代,這裡就只會直接回傳使用量。

    p.s. 以上假設需要查詢的目錄是 dirname.


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word