du -sh * | sort -hr
顯示
2.4G share
2.4G local
1.8G lib64
1.6G lib
368M bin
262M include
218M src
121M libexec
63M sbin
0 tmp
0 games
0 etc
其中,du命令,-s表示summary統計,-h表示人類;sort的參數,-h同樣表示人類,-r表示反向顯示。
如果只是列當前目錄下的文件,不包括子目錄的大小,則直接用
ls -lSh
顯示
-rw-r--r--. 1 root root 18K Nov 28 2016 COPYING
drwxr-xr-x. 2 root root 4.0K Feb 11 20:04 bin
drwxr-xr-x. 3 root root 4.0K Feb 11 20:04 include
drwxr-xr-x. 10 root root 4.0K Feb 11 20:05 mysql-test
drwxr-xr-x. 28 root root 4.0K Feb 11 20:05 share
-rw-r--r--. 1 root root 2.5K Nov 28 2016 README
drwxr-xr-x. 4 root root 191 May 4 11:39 lib
drwxr-xr-x. 2 root root 112 Feb 11 20:05 support-files
drwxr-xr-x. 2 root root 55 Feb 11 20:04 docs
drwxr-xr-x. 4 root root 30 Feb 11 20:04 man
這裏的-h表示人類,-S表示按照大小排序,其中如果是目錄,則顯示目錄文件的大小,而不是目錄裏所有文件的大小。