You can look at the size of your directories and subdirectories.

In addition to using ls -l to find out how big a particular file is, you can find out how much space an entire directory is using up with the du command. For example:

% du
563  ./misc
2    ./Mail/inbox
1    ./Mail/drafts
1    ./Mail/detach.dir
1    ./Mail/index.dir
2573 ./Mail/SAVED
564  ./Mail/94.03.08
482  ./Mail/94.01.03
232  ./Mail/INACTIVE
7185 ./Mail
92   ./mgmt/coop
99   ./mgmt
   ...

By default, du shows you the size of each subdirectory before it shows you the total size of the directory. This is useful if you want to track down where all your disk space is. For example, this listing tells me that most of my space is taken up saving mail messages. But if you want to know a total for a directory, it’s better to use the -s option to get just a grand total:

% du -s
14942 .

du reports sizes in kilobytes, which is the same unit used by df. If you remove a large file, you’ll see the difference when you next run du. For example, if I remove a 2,000-kilobyte file, that change is reflected in my du listing:

% ls -l ch07.ps -rw-r--r-1 lmui 2163514 Sep 16 1993 ch07.ps ...

Get WYNTK: UNIX System Admininistrator now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.