Why disk space not change after remove large files in Linux
One of the common issues faced by Linux users is that even after removing large files, they still do not see any change in the disk space. This can be quite confusing, especially if you are trying to free up some space on your system. In this blog post, we will discuss the reasons why disk space doesn’t change after removing large files in Linux.
The File is Still Open
One of the reasons why disk space doesn’t change after removing large files is that the file is still open. If a file is open, it is still being used by a process, even if you have deleted it. The space used by the file is not freed until the process using the file is terminated or closed. To check if a file is open, you can use the
lsof command followed by the filename. Once you have identified the process using the file, you can terminate it using the
Deleting unused files
rm -f filename
If the file handle is open/writing, directly
rm will not release the disk space. In this case, you can consider freeing up file space by redirecting.
Emptying in-use files
cat /dev/null > filename ## or : > filename ## or > filename ## or echo "" > filename ## or echo > filename
In conclusion, disk space doesn’t change after removing large files in Linux due to various reasons such as the file still being open, in use by a running process, or in the trash folder. By understanding these reasons and using the appropriate commands, you can free up space on your system and optimize its performance.
Small world. Big idea!
- Welcome to visit the knowledge base of SRE and DevOps!
- License under CC BY-NC 4.0
- No personal information is collected
- Made with Material for MkDocs and generative AI tools
- Copyright issue feedback me#imzye.com, replace # with @
- Get latest SRE news and discuss on Discord Channel