Can't remove a directory in Unix

2019-03-13 00:16发布

I've got a seemingly un-deletable directory in Unix that contains some hidden files with names that start with .panfs. I'm unable to delete it using either of these commands:

rm -R <dir>
rm -Rf <dir>

Does anyone have any suggestions?

5条回答
仙女界的扛把子
2楼-- · 2019-03-13 00:21

Syntax :

rm -rf <Directory_Name>

It worked for me. It will remove the directory with all its content ...(forcibly)

查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-13 00:31

to those who prefers to separate the options for a full mastering of their linux command lines so :

$ rm -r -f your-dir-name/

rm → remove

-r → recursively

-f → force (even protected with chMod permissions)

查看更多
forever°为你锁心
4楼-- · 2019-03-13 00:39

Try to delete it with root user or use sudo, if you are in trouble

Use rm -rf dir with root account and it will be deleted, since you should be facing a permissions issue.

查看更多
狗以群分
5楼-- · 2019-03-13 00:43

Sorry, but voted 20+ approved solution didn't work for me :) but I nailed the sucker.

In my case, under root, rm -rf (directory) leads to an infinite loop, and size of the folder is under a gig. Furthermore, the folder is non-listable that is using the dir command within the folder also leads to infinite loop.

Oh Hell no!!!

Enter recovery mode by holding on to left shift at boot. Provide your root password or press enter if there is none.

cd /

mount -o remount,rw /

rm -f (directory) //Purpose is to fix loop bug

rm -r (directory)

See ya!

All hail Linux Lite.

查看更多
家丑人穷心不美
6楼-- · 2019-03-13 00:47

Check with df dir and mount how is your directory mounted and to which file system it belongs to. Notice that if you use NFS, CIFS/SMB, or some other distributed file system, you could have issues... since distributed file systems are caching (both server side and client side) so don't have POSIX semantics. See filesystems(5).

Very probably you are using NFS (then your question should say that, and give much more details, notably mount and export options in /etc/fstab, see fstab(5), version of NFS protocol used, etc...). Then you need to give more details about how it is exactly mounted, if you have processes using that file system (use lsof(8)...), and how authentication works. Quite often, root access does not exactly work thru NFS as you want it to... (intuitively your local root is not a network-wide root).

In some cases, you need to remove files on the NFS server after having unmounted that remote NFS file system on all NFS clients. And details vary with version of NFS protocol used and configuration options.

See also nfsd(7), exports(5) etc and this question on Serverfault, and this Linux NFS overview.

查看更多
登录 后发表回答