[Cialug] Unable to remove a directory in RedHat7

Zachary Kotlarek zach at kotlarek.com
Thu Aug 21 17:29:12 CDT 2014


On Aug 21, 2014, at 2:29 PM, Tom Sellers <tomsellers2001 at yahoo.com> wrote:

> I have been trying to clean up my old linux box that I used as a server and make sure I did not leave anything on there important.  In the process of doing so I have run into a directory that I can't delete.  It says it is not empty but I am unable to see any files in that directory when I am logged on as the root user.  
> 
> Is there a way to remove the directory regardless of whether there are any hidden files in it?
> 
> I tried a command I found on line rm -rf filename but that does not work.  Just tells me directory is not empty.


To start with a simple:
	ls -Rla <path>
should show you everything in the directory, including hidden files. If that doesn’t show anything it’s unlikely the problem is really the contents of the directory.

Other reasons the directory may not be able to be deleted include:
1. It’s in use by some process. You can determine which with the command:
	lsof | grep <path>
which will show any processes that have matching paths open by any means.

2. The directory or something in it may be marked immutable. You can clear that with:
	chattr -R -i <path>
which recursively clears the immutable flag on everything under <path>.

3. The filesystem itself is corrupt. This is unusual but can sometimes lead to files/directories that cannot be manipulated in the usual ways. `fsck` should be able to tell you if that’s the case — just remount the disk read-only and force a full scan.

	Zach

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2749 bytes
Desc: not available
URL: <http://cialug.org/pipermail/cialug/attachments/20140821/0dd9270e/attachment.bin>


More information about the Cialug mailing list