Sometimes we need delete a directory that is not empty and we get permission errors such as "Permission denied" or also "Directory not empty" when trying to do so because it is not empty and perhaps some of the directories or files it contains have special permissions that are the cause of the error. But it is possible to eliminate it easily with the minitutorial that we now offer you and make these messages not impediments to do so.
En a previous tutorial We saw how to be able to eliminate directories with quite extensive content, that is, directories with a considerable weight of several GB without affecting the performance of the system. And we achieved this thanks to ionice, a very practical tool that allows us to control the priority of certain transactions in the I / O system, as nice does with processes. Well, today we will focus on another simple action, but that may be giving some problem to the newest Linux users.
The steps to follow when we try to delete our directory that is not empty would be to try with:
But in that case we can receive the error message we were talking about. To do it correctly, you can try the following:
rm -rfv /mi-directorio
What we get with these rm options is a recursive deletion for the contents of the directory and also force deletion respectively. The -v is simply the verbose mode of the command to display more information on standard output.
In the event that we still get the permission error, because we will try to obtain privileges so that we no longer have problems when trying to delete it, you can do it with su, or more recommended with sudo:
sudo rm -rfv /mi-directorio
I hope it helped you with those stubborn directories that cannot be removed ...