e Learning

Linux df -h Command Shows Wrong Disk Space Usage

Do you Think Your Linux Server Display Wrong Disk space usage when you type df -h command in the terminal, even after you delete lots of files and folders?

This is because even If you Deleted some files, Program that use those files still keep open Files you Just Deleted, So first you need to find out what are the deleted files that are still open, to find out that we can use lsof command (List Open Files), open Linux Terminal and Type

lsof -n | grep deleted

Are you getting any output? If you are, then find what program uses those open files and restart the related services.

For example, Once Myself Get into This Problem. One of our company Web Server was running out of disk space and I noted that there are large number of Access and Error log files created by Apache Web Server. Since Old log files haven’t removed for a sometimes total of those files was more than 10GB. So I removed Total of 8GB of those files and the run the df -h Command. But for my surprise Disk Space shows by df command are still the same. Only when I run the lsof command that I realized all those log files that I Deleted still keep Holding by Apache Process. So what I did is simply Restart The Apache Service and run df -h Command again and this time everything is fine.