I want delete the .gitconfig folder in my user's home directory on Ubuntu 20-.04 (WSL2) but I'm getting this strange error:
rm: cannot remove '.gitconfig/': Device or resource busy
I've tried testing through lsof but no results show up.
I had the same issue: I could delete this folder from Windows, by going to \\wsl$\Ubuntu-20.04\home\<my_username>
and deleting .gitconfig
folder, but it was immediately recreated.
Turns out that what was keeping it busy is the Docker integration for WSL2.
I stopped the (Windows) process, and I was able to rm -R ~/.gitconfig
from windows.
I then created the file ~/.gitconfig to prevent Docker from repeating this nasty behavior
The trailing slash in the error message makes it look as though .gitconfig is a directory. Do you have an application open - Linux shell, Windows Explorer? - with .gitconfig as its current directory? If so, close that application and try again. Or, reboot the host.