Linux 无法在 Unix 中删除目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16947559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't remove a directory in Unix
提问by fugu
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:
我在 Unix 中有一个看似不可删除的目录,其中包含一些名称以.panfs
. 我无法使用以下任一命令删除它:
rm -R <dir>
rm -Rf <dir>
Does anyone have any suggestions?
有没有人有什么建议?
采纳答案by Paulo Fidalgo
Try to delete it with root useror use sudo, if you are in trouble
如果遇到麻烦,请尝试使用root 用户或使用sudo删除它
Use rm -rf dir
with root account and it will be deleted, since you should be facing a permissions issue.
使用rm -rf dir
root 帐户,它将被删除,因为您应该面临权限问题。
回答by LinuxLite
Sorry, but voted 20+ approved solution didn't work for me :) but I nailed the sucker.
对不起,但投票 20+ 批准的解决方案对我不起作用 :) 但我搞砸了。
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.
在我的情况下,在 root 下, rm -rf (目录)导致无限循环,文件夹的大小在 gig 下。此外,文件夹不可列出,在文件夹内使用 dir 命令也会导致无限循环。
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.
通过在启动时按住左移进入恢复模式。提供您的 root 密码,如果没有,请按 Enter。
cd /
光盘 /
mount -o remount,rw /
mount -o 重新挂载,rw /
rm -f (directory) //Purpose is to fix loop bug
rm -f (directory) //目的是修复循环bug
rm -r (directory)
rm -r(目录)
See ya!
拜拜!
All hail Linux Lite.
所有冰雹Linux Lite。
回答by Basile Starynkevitch
Check with df
dirand mount
how is your directory mounted and to which file systemit 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).
检查df
dir以及mount
您的目录是如何挂载的以及它属于哪个文件系统。请注意,如果您使用NFS、CIFS/SMB或其他一些分布式文件系统,您可能会遇到问题......因为分布式文件系统正在缓存(服务器端和客户端),所以没有 POSIX 语义。请参阅文件系统(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).
很可能您正在使用 NFS(那么您的问题应该说明这一点,并提供更多详细信息,特别是 中的挂载和导出选项/etc/fstab
,请参阅fstab(5),使用的 NFS 协议版本等...)。然后,您需要提供有关它是如何确切安装的更多详细信息,如果您有使用该文件系统的进程(使用lsof(8)...),以及身份验证如何工作。很多时候,root 访问并不像您希望的那样通过 NFS 完全工作......(直觉上,您的本地根不是网络范围的根)。
In some cases, you need to remove files on the NFS server afterhaving unmounted that remote NFS file system on all NFS clients. And details vary with version of NFS protocol used and configuration options.
在某些情况下,您需要在所有 NFS 客户端上卸载该远程 NFS 文件系统后删除 NFS 服务器上的文件。详细信息因使用的 NFS 协议版本和配置选项而异。
See also nfsd(7), exports(5), chattr(1)etc and this questionon Serverfault, and this Linux NFSoverview.
另请参阅nfsd(7)、exports(5)、chattr(1)等以及关于 Serverfault 的这个问题,以及这个Linux NFS概述。
回答by Shireesh Kumar
Syntax :
句法 :
rm -rf <Directory_Name>
It worked for me. It will remove the directory with all its content ...(forcibly)
它对我有用。它将删除目录及其所有内容......(强制)
回答by marcdahan
to those who prefers to separate the options for a full mastering of their linux command lines so :
对于那些喜欢将选项分开以完全掌握其 linux 命令行的人,因此:
$ rm -r -f your-dir-name/
rm→ remove
rm→ 删除
-r→ recursively
-r→ 递归
-f→ force (even protected with chMod permissions)
-f→ 强制(甚至受 chMod 权限保护)