
我無法刪除 Linux 中的某些檔案。這裡是例子:
[root@HBL01 home]# ls -ltira index.php
393591 -r--r--r-- 1 apache apache 14335 Nov 23 2021 index.php
[root@HBL01 home]# rm -rf index.php
該文件存在:
[root@HBL01 home]# ls -ltira index.php
393591 -r--r--r-- 1 apache apache 14335 Nov 24 2021 index.php
[root@HBL01 home]# lsattr index.php
--------------e----- index.php
我嘗試寫一些東西維姆但最後出現此訊息:
"index.php" [readonly] 17L, 14335C
嘗試更改權限但...無法正確運行:
[root@HBL01 ]# chmod 777 index.php
[root@HBL01 ]# ls -ltra index.php
-r--r--r-- 1 apache apache 8230 Nov 23 2021 index.php
我嘗試刪除該文件(無輸出),但該文件仍然存在。
[root@HBL01]# lsattr index.php
--------------e----- index.php
[root@HBL01]# rm -rf index.php
[root@HBL01]# ls -ltrh index.php
-r--r--r-- 1 apache apache 8.1K Dec 11 2021 index.php
[root@HBL01]# fuser index.php
[root@HBL01]# ls -ld index.php
-r--r--r-- 1 apache apache 8211 Dec 11 2021 index.php
究竟發生了什麼事?我怎麼才能刪除這個檔案?
先致謝!
問題仍然存在:
[root@HBL01]# lsattr index.php
--------------e----- index.php
[root@HBL01]# rm -rf index.php
[root@HBL01]# ls -ltrh index.php
-r--r--r-- 1 apache apache 8.1K Dec 11 2021 index.php
答案1
嘗試這個:
chattr-i索引.php; rm -rf 索引.php
答案2
該文件是否可寫入(看起來不是)? chmod +w index.php 然後 rm -rf index.php 或一步(可貼上);
chmod +windex.php; rm -rf 索引.php
如果沒有結果,請嘗試在同一目錄中建立文件,然後執行 ls -al,然後刪除新建立的文件。這可以透過以下方式實現:
觸摸檔名01.tmp; ls -al 檔名01.tmp; rm 檔名01.tmp
試一試,讓我知道進展如何。如果沒有,請貼上第二個命令提供的任何輸出。它應該給出您創建的 filename01.tmp 檔案的清單。我們可能可以透過這樣做學到一些東西,從而找到解決方案。