Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I want to see how much total space / is taking, but I don't know how to do that. I can use ls -hal and add up the subtotals, or I can use fdisk to tell me the size of that partition, but is there a better way?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

Are you asking about the total size of files/directories contained within /, or the total size of the root filesystem?

If the former, use df -h /.

If the latter, you can do this with du -sh /, which will be very slow, as it has to enumerate every single file. Better, but possibly inaccurate due to things like bind mounts, filesystems stored as sparse files on other filesystems/etc: total up your df output.

share|improve this answer
Also note that for accurate results, du needs to be executed as root. Otherwise there will be directories it cannot descend into, and you won't get a complete tally. – Michael Kjörling Dec 22 '12 at 15:39
I meant the former. Thanks. I hadn't heard of df before. – Korgan Rivera Dec 22 '12 at 18:22
@KorganRivera you'd also want to use the -x switch to make sure different filesystem mounted in the directory are skipped. – peterph Dec 22 '12 at 23:00
@peterph - You're mistaken, the second example implies that that is desired. – Chris Down Dec 23 '12 at 12:10
@ChrisDown - not sure what second example. It should almost never be desired - once you have a network mount, running du on it is a killer (e.g. with the usual home or shared data mounts which can be on the order of hundreds of GBs). – peterph Dec 23 '12 at 19:45
  • df reports filesystem metadata - i.e. what the filesystem is capable of storing at the moment. Important thing to note is that on some filesystems this does not necessarily need to reflect the free space (it is the available space though), since the fs can do preallocations when it thinks it's a good idea (for example XFS may do this when you start creating a big file - it will allocate additional space to ensure the file is less scattered and doesn't spend too much time with allocations when it will need to write the actual data to disk). Such space is marked as available with some delay. The information also reflects the fact, that some space on the disk is (or might be) needed by the filesystem structures - this can cause a curious effect on some filesystems: reporting more than 100% space use.

  • du will give you the real disk usage with filesystem blocks granularity (on most systems, not sure about those that can use one block for data of several files). Since it has to stat() every file belonging to the top directory hierarchy (the one du is given on the command line), it's slow, especially for cases with small files.

  • stat will give you information about a single file (or directory for that matter).

Hence if you want to know:

  • how much free space you have on a filesystem (approximately), use df;

  • how much data you really have in the files (not necessarily on a single filesystem), use du - be aware that it can easily get slow especially on some network filesystems;

  • how much space the record for the root directory itself occupies, use stat / .

share|improve this answer

There are usually no files in the root directory, so I assume you want to know how much space is used in the root filesystem. The command for this is df (disk free).

df -h /

With no arguments, df provides usage information for all filesystems (except some special, non-disk-backed filesystems for which this is irrelevant).

If you want to know how much space is used by a directory and its subdirectories, that don't make up the full filesystem, use du (disk usage).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.