I have this folder in Ubuntu 18.04 that I completely removed.

sudo rm -rf folder_name

It has been deleted, but after a while, the folder comes back, but only with the .cache directory in the folder. It takes about 1 minute until the folder comes back with only the .cache folder in the folder that I want to delete.

I change the permission of the both the .cache folder and the folder itself, deleted them, but it keeps coming back. I also deleted everything piece by piece.

There is also in the .cache folder a pgdata folder.


[edit] Yeah so I was able to finally delete it. As someone pointed out, a process was creating that folder in the background. It was a docker container.

  • There must be a process creating the folder. Where is it located? – guillermo chamorro Jul 4 at 17:32
  • 2
    It seems to be a PostgreSQL folder – guillermo chamorro Jul 4 at 17:34
  • Yeah that was exactly the problem! It was a docker container (running postgresql) that was still running in the background. I stop and deleted the container and was able to delete the folder! Thanks! – Mathieu Châteauvert Jul 4 at 17:49
  • 1
    Without specifying the folder_name this isn't a good question. However, more generically if you use lsof | grep "folder_name" (with the internal double quotes) then lsof will give you a list of the processes that have a folder open. lsof | grep "cache" will show you a ton of processes with caches; less blunt is lsof +c0 +d "/home/$USER/.cache" which shows all processes with files open from the ~/.cache directory. – pbhj Jul 4 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.