简体   繁体   中英

centos cannot delete a directory

I am trying to delete the directory 'dirr':

/package/python-2.7.9/lib/python2.7/site-packages/dirr/

I have tried rm -rf

sudo rm -rf dirr

rm: cannot remove `dirr': Directory not empty

When I check what is inside the directory,

[root@my_pc dirr]# ls
ls: cannot access __init__.pyc: No such file or directory
ls: cannot access __main__.py: No such file or directory
ls: cannot access __main__.pyc: No such file or directory
ls: cannot access _execution.py: No such file or directory

_execution.py  __init__.pyc  __main__.py  __main__.pyc  

I have no idea what is going on.

Here is some extra information:

centos-release-6-6.el6.centos.12.2.x86_64

ls -al
?????????? ? ?    ?       ?            ? _execution.py
?????????? ? ?    ?       ?            ? __init__.pyc
?????????? ? ?    ?       ?            ? __main__.py
?????????? ? ?    ?       ?            ? __main__.pyc

A possible workaround:

mv -f /package/python-2.7.9/lib/python2.7/site-packages/dirr/ /tmp/

If it works, then you can just reboot and see if the directory is deleted (in many Linux distributions /tmp/ gets "cleaned" at boot, not sure about yours -- if not, then try to delete it manually from /tmp/).

Another possible workaround:

rm -ri /package/python-2.7.9/lib/python2.7/site-packages/dirr/

This will bring a question about deleting each one of the problematic files -- choose "y" and see if they get deleted.

If that does not work, try finding the inode of each file inside the folder and deleting it via inode, like:

ls -li /folder/ example output: 918625 -rw-r--r ...etc

and then delete each of the files with find:

find /folder/ -inum 918625 -delete

I don't have a definite answer to your question, but I had a similar problem on CentOS recently -- I was seeing garbage for file stats on ls , just as you do.

Are your files residing on an ext2 partition?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM