Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

Disk free information

The du command provides information about the usage, while df provides information about free disk space. Use -h with df to print the disk space in a human-readable format. Consider this example:

    $ df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda1             9.2G  2.2G  6.6G  25% /
    none                  497M  240K  497M   1% /dev
    none                  502M  168K  501M   1% /dev/shm
    none                  502M   88K  501M   1% /var/run
    none                  502M     0  502M   0% /var/lock
    none                  502M     0  502M   0% /lib/init/rw
    none                  9.2G  2.2G  6.6G  25%   
    /var/lib/ureadahead/debugfs

The df command can be invoked with a folder name. In that case, it will report free space for the disk partition that contains that directory. This is useful if you don't know which partition contains a directory:

    $ df -h /home/user ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985