我登录了rhel 7 box(一个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
如何删除该文件夹?
答案 0 :(得分:1)
如果文件夹为空,您是否尝试使用简单引号中的完整路径rmdir
命令? ''
如果这不起作用,你既不能找到该文件夹的inode,然后通过它的inode删除它?
ls -il <path> #get the inumber, let's say it's 782353
然后,find . -inum <782353> -exec rm -ir {} \;