我登录了rhel 7框(一个docker容器)并以root身份运行。我试图删除目录,但不断收到无效参数错误。这是我的命令
[root@sandbox ~]# rm -rf /var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/5.5.2.2.5
rm: cannot remove `/var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/5.5.2.2.5': Invalid argument
这是该文件夹的权限
[root@sandbox ~]# ls -lrth /var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/
total 4.0K
drwxr-xr-x 1 root root 4.0K Nov 7 07:50 5.5.2.2.5
该文件夹实际上是空的:
[root@sandbox ~]# ls -lrth /var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/5.5.2.2.5/
total 0
试图用引号引起来的路径也不起作用:
[root@sandbox ~]# rmdir "/var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/5.5.2.2.5"
rmdir: failed to remove `/var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/5.5.2.2.5': Invalid argument
使用inode删除也不起作用:
[root@sandbox ~]# ls -il /var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/
total 4
98616 drwxr-xr-x 1 root root 4096 Nov 7 07:50 5.5.2.2.5
root@sandbox ~]# find . -inum 98616 -exec rm -i {} \; # doesn't throws error but the folder is still there
[root@sandbox ~]# ls /var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/
5.5.2.2.5
使用find删除也不起作用:
[root@sandbox ~]# find /var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/ -type d -exec rm -Rf {} \;
rm: cannot remove `/var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/5.5.2.2.5': Invalid argument
rm: cannot remove `/var/lib/ambari-server/data/tmp/solr-service/custom-services/SOLR/5.5.2.2.5': Invalid argument
如何删除该文件夹?
最佳答案
如果文件夹为空,您是否尝试过rmdir
命令而不是用简单的引号引起来的完整路径? ''
如果这不起作用,您也找不到文件夹的 inode ,然后通过其 inode 将其删除吗?
ls -il <path> #get the inumber, let's say it's 782353
然后,
find . -inum <782353> -exec rm -ir {} \;
关于linux - 为什么Linux rm -rf引发无效参数错误?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47152904/