Finding Directory Size and Drive Space - Debian Manual

One of the things I find that I need to do every now and then is find out how much space a particular directory is taking up on the hard drive. This is fairly easy to do using a file browser such as konqueror as you simply right click on the directory and select properties. Quite often though I need to perform the same task from the command line (typically because something has gone sideways and filled up a drive - sigh).

Directory Size

The command to use is situation is du and various useful examples of this command are shown below. The man page, of course, provides full coverage.

du

Entering just du will provide you with a pretty comprehensive output of the size of the current directory and every directory under it in a recursive manner. The displayed size is in kilo bytes and is listed for each directory. Personally, I find this less than useful and I think a better default action would be the command shown below.

du --max-depth=1 -h

This version of du will list the total size of each directory under the current directory but only recurse one level deep. It will also display the sizes in a human readable format (e.g. megabytes, gigabytes, etc)

du /foo/bar

Useful when you only want to know about one particular directory.

du -a

Prints out the size of every file and directory under the current directory - be prepared for a lot of output.

du -s

Show just a summary for each argument

du -S
Don't include the size of sub-directories in the total. This gives you the size of just the files in the current directory.

Drive Size / Used Space

If you want to find out how much space you are using on a drive use:

df -h
  • Email, SSL
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to Install Kloxo on RHEL or CentOS VPS

The Kloxo installation process differs depending on whether you have already setup MySQL. If you...

How to Import/Export MySQL Databases with SSH

To export a MySQL database, access your VPS via SSH and run: # mysqldump -u username -p...

تغییر پورت ssh

برای تغییر پورت SSH مراحل زیر را پیگیری نمایید:با دسترسی root به ssh وارد شوید و فایل nano...

نحوه تشخیص نسخه لینوکس

برای فهمیدن نسخه کرنل از دستور:uname -a :و برای فهمیدن نوع سیستم عامل از دستور cat...