Apologies if this a dumb question, but i have not found an answer yet.

How do you find out how much free disk/file space for a given folder or partition.

Basically i need to know how much free space there is before i carry out a tasks on the server and don't wish to hit the limits unexpectedly.

thanks in advance.

  • 1
    Not a dumb question :)
    – bedwyr
    Jun 6, 2009 at 1:21

12 Answers 12

df -h # shows free disk space on all partitions
du -hs foldername # shows space used by a particular folder
  • 2
    du -h was always my favorite thing to say to a coworker. Jun 5, 2009 at 19:58

chaos answered first, but I just wanted to add "df -h" is more useful (display it in human-readable terms (MB, GB, KB, etc) instead of blocks), but you can figure that out from df's help page.

   cd /path/to/dir
   df -h .
   Filesystem            Size  Used Avail Use% Mounted on
   /dev/sda1              36G   20G   14G  60% /
  • you mean du -h . df -h as chaos said shows free disk on all partitions and it doesn't care about your PWD
    – Zypher
    Jun 6, 2009 at 2:25
  • 1
    It does, if you make a simple df -h it will show all filesystems mounted, if you give it a path it will only show the free space for the filesystem mounted there..
    – rkthkr
    Jun 9, 2009 at 9:01

my favorite trick for getting the really big files listed:

du | sort -rn | head

gets the top 10 filepigs listed.



A little out of the scope of the question, but as 'df' and 'du' are already well covered... if you find the two don't match, it's useful to use the command 'lsof +L1' to list deleted, but still open files.

Your diskspace will not be freed up if a deleted file is still open until it is closed (seen this a lot with improper log rotation setups).

  • Even though it's been 5 years since you wrote this, I just want to say thank you! That helped me out.
    – Adam Plumb
    Aug 15, 2014 at 13:00

You want df. (And df -i for inodes free.)


I know this is tagged linux, but in the interest of completeness..

The -h option isn't always available. I know Solaris, etc doesn't have it on their tools (du, df, ls, etc).

  • I thought Solaris 10 was including the "good" tools with -h. Hmm. Jun 5, 2009 at 20:57

The manual page that's quoted shows it, and rkthkr's answer uses it but it's not highly visible: if you specify a pathname at the end of the df command line, it limits its display to the filesystem containing that path only.

If you want to trim off the header line then pipe it through tail -1, and to grab just the free space column, pipe that through awk '{print $4}' (or a cut selecting the appropriate field or columns).


As others suggested, use df for locally mounted disks that you're managing.

For NFS and other remote mounted volumes, you may encounter a quota system. For these systems, use the "quota" command to find out how much free quota remains, which will likely be smaller than the number of bytes remaining. This is not always true, though.

You can find more about quota here: http://www.tldp.org/HOWTO/Quota.html


df - report file system disk space usage (man)

df [OPTION]... [FILE]...
This manual page documents the GNU version of df. df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown. Disk space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

If an argument is the absolute file name of a disk device node containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node (which is always the root file system). This version of df cannot show the space available on unmounted file systems, because on most kinds of systems doing so requires very nonportable intimate knowledge of file system structures.

Show information about the file system on which each FILE resides, or all file systems by default.

Mandatory arguments to long options are mandatory for short options too.

-a, --all
    include dummy file systems 
-B, --block-size=SIZE use SIZE-byte blocks
-h, --human-readable
    print sizes in human readable format (e.g., 1K 234M 2G) 
-H, --si
    likewise, but use powers of 1000 not 1024 
-i, --inodes
    list inode information instead of block usage 
    like --block-size=1K 
-l, --local
    limit listing to local file systems 
    do not invoke sync before getting usage info (default) 
-P, --portability
    use the POSIX output format 
    invoke sync before getting usage info 
-t, --type=TYPE
    limit listing to file systems of type TYPE 
-T, --print-type
    print file system type 
-x, --exclude-type=TYPE
    limit listing to file systems not of type TYPE 

du - estimate file space usage (man)

du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F

Summarize disk usage of each FILE, recursively for directories.

Mandatory arguments to long options are mandatory for short options too.

-a, --all
    write counts for all files, not just directories 
    print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in ('sparse') files, internal fragmentation, indirect blocks, and the like 
-B, --block-size=SIZE use SIZE-byte blocks
-b, --bytes
    equivalent to '--apparent-size --block-size=1' 
-c, --total
    produce a grand total 
-D, --dereference-args
    dereference FILEs that are symbolic links 
    summarize disk usage of the NUL-terminated file names specified in file F 
    like --si, but also evokes a warning; will soon change to be equivalent to --dereference-args (-D) 
-h, --human-readable
    print sizes in human readable format (e.g., 1K 234M 2G) 
    like -h, but use powers of 1000 not 1024 
    like --block-size=1K 
-l, --count-links
    count sizes many times if hard linked 
    like --block-size=1M 
-L, --dereference
    dereference all symbolic links 
-P, --no-dereference
    don't follow any symbolic links (this is the default) 
-0, --null
    end each output line with 0 byte rather than newline 
-S, --separate-dirs
    do not include size of subdirectories 
-s, --summarize
    display only a total for each argument 
-x, --one-file-system
    skip directories on different file systems 
-X FILE, --exclude-from=FILE
    Exclude files that match any pattern in FILE. 
--exclude=PATTERN Exclude files that match PATTERN.
    print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize 
    show time of the last modification of any file in the directory, or any of its subdirectories 
    show time as WORD instead of modification time: atime, access, use, ctime or status 
--time-style=STYLE show times using style STYLE:
    full-iso, long-iso, iso, +FORMAT FORMAT is interpreted like 'date' 

Great answers above.

One thing I would like to add is that df- hP give you output thats more easily parsed. (P is for portability)


in my case, 'lsof +L1' was the answer. a bunch of apache logs, deleted but not

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .