Finding Out About File System Use in Linux.

Running out of disk space can be annoying on your desktop system and potentially a disaster on your servers. To determine how much disk space is available and how much is currently in use, you can use the “df” command. To check how much space particular files and directories are consuming, use the “du” command.
The “df” command provides the “-h” options which output in a human-readable, usually in MB or GB.
This command display space on file systems in human-readable form

[root@Fedora11-vbox ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
                      6.7G  3.6G  2.9G  56% /
/dev/sda1             194M   21M  163M  12% /boot
tmpfs                 250M  292K  250M   1% /dev/shm

If you have remote share mounted, these will show up too. So to limit the output to local systems only:

df -hl

To check for disk space usage for particular files or directories in a file system:

[root@Fedora11-vbox ~]# du -h /home/
4.0K	/home/smbuser/.mozilla/plugins
4.0K	/home/smbuser/.mozilla/extensions
12K	/home/smbuser/.mozilla
4.0K	/home/smbuser/.gnome2

If you have root priviliges, you can use the “-s” option to get a summary of disk usage; otherwise, you will get “permission denied” when trying to access directories that you don’t have access to.

[root@Linux-box ~]# du -sh /home
1.1G    /home

You can also specify multiple directories with the “-c” option.

[root@Linux-box ~]# du -sch /home /var
1.1G    /home
126M    /var
1.2G    total

You can specify how deep in the subdirectory tree you want to search. The “–max-depth” option let you set the depth of the search. In the following example with give “–max-depth” equals to “1” so the search will travel one level deep than the specified folder.

[root@Linux-box ~]# du --max-depth=1 /home
72      /home/sam
24      /home/home
1049804 /home/jorge
8       /home/samba
1049916 /home
Share This!

Add a Comment

Your email address will not be published.

Sign up for our Newsletter

Download "Google Search Pro"

Enter your email and stay on top of things,