Sobes.tech
Junior — Middle

What would you do if your colleague regularly deletes files using the 'rm -rf' command, but the files still remain and do not free up disk space?

sobes.tech AI

Answer from AI

If files are deleted with the command rm -rf, but disk space is not freed, it is likely that these files are still held open by some process. In Linux/Unix, when a file is deleted from the filesystem but is still open by a process, it remains in memory and the space is not freed until the file descriptor is closed.

What to do:

  • Use the command lsof | grep deleted to find processes that have deleted files open.
  • Restart or terminate these processes to free the file descriptors and disk space.
  • Check that the deletion is happening in the correct directory and that there are no symbolic links pointing elsewhere.

Example:

lsof | grep deleted

This will show processes that hold deleted files. After they are terminated, the space will be freed.