LINUX

LINUX DU指令

介紹

du指令用來顯示檔案(夾)的磁碟使用量。

語法

du [options] [files | directories]

常用的options

-b     Measure usage in bytes.

-k     Measure usage in kilobytes.

-m     Measure usage in megabytes.

-B N   Display sizes in blocks that you define, where 1 block = N bytes. (Default=1024)

-h -H  Print in human-readable units. For example, if two directories are of size 1 gigabyte or 25 kilobytes, respectively, du -h prints 1G and 25K. The -h option uses powers of 1024, whereas -H uses powers of 1000.

-c     Print a total in the last line. This is the default behavior when measuring a directory, but for measuring individual files, provide -c if you want a total.

-L     Follows symbolic links and measure the files they point to.

-s     Print only the total size.

範例

你可以顯示檔案(夾)的磁碟使用量,預設單位為區塊(Block):

⤍ du myfile
4       myfile

⤍ du myfile emptyfile hugefile
4       myfile
0       emptyfile
18240   hugefile

如果沒有指定檔案(夾),則會顯示當前目錄及所有子目錄的磁碟使用量:

⤍ du
188	./dir1
352	./dir2/mydir
356	./dir2
68	./dir3
616	.

發佈留言