Why do "df" and "du" commands show different disk usage?

I cannot access ubuntu system on my pc, the error message: "the system is running in low graphics mode" and I tried some commands I searched from internet.

I found out a problems seems there is no available disk space. I used "df" and "du" commands to check, the results are as follow:

du -j --max-depth=1
23G  ./home
3.3G ./usr 
...... 
28G

and

df -Th 
filesystem   Type   size    used   available   use%    mounted on 
/dev/sda5    ext4   68G     68G    0           100%    /

how would I clean up the system for more disk space?


You most probably know that you can remove a file that still in use by some application and for this application it remains available. It because file descriptor in /proc/ filesystem is held open.

So if there are such open descriptors to files already removed, space occupied by them considered as used by df (and df is right), but they can not be taken into account by du due to there are no longer filenames associated with them.

You can find all unlinked but held open files with:

# lsof | grep '(deleted)'

How can i delete the links? – Vikas Hardia Aug 22 '14 at 5:46

You must find the the process which holds the file handle. Use the command of Dmitry Alexandrov, there you see the process and pid. In our case and "old" varnish log file was the space killer.

# lsof | grep '(deleted)'
[...]
varnishlo 13978       varnishlog    3w      REG              252,1 318448027646    5926973 /var/log/varnish/varnish.log.1 (deleted)
apache2   16801         www-data    2w      REG              252,1        64550   13110120 /var/log/apache2/error.log.1 (deleted)
[...]
# service varnishlog stop
[or if there is no service script]
# kill -11 13978 (the second number of the lsof command is the pid)
[or may be] 
# kill -9 13978

Don't forget to start the service or process again if it is a demon or some other service on your computer. If you can, just reboot the computer ;)