Unix Du (Disk Usage Command)

Posted On 2007-04-14 by FortyPoundHead
Tags: Tip Windows XP
Views: 2463

Most Unix operating systems come with a du command for users and system administrators to help determine which directories use the most file space. This is useful if file space is getting low and one needs to determine where to start looking for files to remove and/or archive.

The Sysinternals website, part of Microsoft TechNet, offers a free replacement for the disk usage command. Simply download a zip file, unzip the executable inside du.zip to your main Windows directory, and you can check disk usage on the command line:

C:\>du .

This will display disk usage in the current directory and subdirectories. Example output:

Du v1.31 - report directory disk usage
Copyright (C) 2005-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

Files: 70
Directories: 2
Size: 3,771,222 bytes
Size on disk: 3,771,222 bytes

(Note that the . is required if you do not attach any other command line options).

To remove the Sysinternals banner:

C:\>du -q

To skip recursion so subdirectory disk usage is not shown:

C:\>du -n

To recurse only n level(s) of directories:

C:\>du -l [LEVEL]

For example, to recurse only 2 levels of directories:

C:\>du . -l 2

The -v command works similar to the Unix du command in that it will display the usage of each recursed directory in kilobytes. For example, to display the disk usage of each folder inside the c:\epson directory:

C:\>du -q -v c:\epson
4,024 c:\epson\epson10001\WINXP
5,014 c:\epson\epson10001
5,014 c:\epson

Files: 46
Directories: 2
Size: 5,134,524 bytes
Size on disk: 5,134,524 bytes

You can also display the file size of only selected files in the current directory and subdirectories. For example, the following command line checks for files starting with news and displays only the disk space used of such files:

C:\documents>du -q news*

Files: 26
Directories: 0
Size: 50,132 bytes
Size on disk: 50,132 bytes

click here to download the program

About the Author

has posted a total of 1974 articles.

Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Code Links