Report File Space Used by a Directory


du

The df command tells you about your entire hard drive, but what if you just want to know how much space a directory and its contents are using? The du command (short for disk usage) answers that question. First you use the cd command to change directories to the directory in question, and then run du.

$ cd music $ du 36582  ./Donald_Fagen 593985 ./Clash 145962 ./Hank_Mobley/1958_Peckin ' _Time 128200 ./Hank_Mobley/1963_No_Room_For_Squares 108445 ./Hank_Mobley/1961_Workout 2662185. 


As with df, results for du are given in kilobytes, but also like df, you can view them in a more comprehensible fashion with the -h (or --human-readable) option.

$ cd music $ du -h 36M    ./Donald_Fagen 581M   ./Clash 143M   ./Hank_Mobley/1958_Peckin'_Time 126M   ./Hank_Mobley/1963_No_Room_For_Squares 106M   ./Hank_Mobley/1961_Workout 2.6G   . 


This output shows you the space used by each subdirectory, but directories that contain other directories also show the total for those contents. Look at the Hank_Mobley directory, which takes up 374MB on this filesystem. That total comes from the three subdirectories contained within Hank_Mobley (since the actual amount in kilobytes was rounded to display megabytes, the totals are just a bit off); if the total for Hank_Mobley was substantially bigger than the total of its three subdirectories, that would mean that the Hank_Mobley directory contained within it several loose files that were outside of a subdirectory.

Finally, you get a total for the entire music/ directory at the end: 2.6GB.



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net