Score:0

Unable to delete file in Centos

cn flag

I can't remove certain file in Linux. Here the example:

[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 

The file exists:

[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

I try to write something with vim but appears at the end this message:

"index.php" [readonly] 17L, 14335C

Tried to change the permisos but... not run correctly:

[root@HBL01 ]# chmod 777 index.php 

[root@HBL01 ]# ls -ltra index.php 
-r--r--r-- 1 apache apache 8230 Nov 23  2021 index.php

I try to remove the file (no output) but the fie persists.

[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

What exactly happend? How can I remove this file?

Thanks in advance!


Problem persists:

[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
user10489 avatar
nc flag
Stop using `rm -rf`. Really. The `-f` option tells rm that you don't care about errors and don't want to know. If you omit that option, you'll find out why it can't delete it. If you are not happy with the answers you've gotten so far, modify your question to include the error that `-f` suppresses.
fr flag
What are the permissions on the directory? Is the disk mounted read-write or read-only? Is the file local or on nfs? If nfs - what are export permissions?
Guif If avatar
cn flag
the file not's on NFS. The directory have a correct permisions because another files on the same directory can be removed.
fr flag
The timestamp before and after the removal is different (23rd versus 24th of Nov). Is it possible that there is some process running which recreates the file? And why does it show year 2021? Try `lsof index.php` (possibly as root) to see if there is any process keeping it open.
Score:0
af flag

try this:

chattr -i index.php; rm -rf index.php

Guif If avatar
cn flag
executed but have the same issue. No output. No error. I can't remove the file
Score:0
af flag

Is the file writable, it doesn't appear so? chmod +w index.php and then rm -rf index.php OR in one (pastable) step;

chmod +w index.php; rm -rf index.php

If no result, try creating a file in this same directory, and then performing an ls -al, and then consequently deleting the newly created file. This can be achieved as follows:

touch filename01.tmp; ls -al filename01.tmp; rm filename01.tmp

Give it a shot and let me know how it goes. If no go, please paste any output the 2nd command provides. It should give a listing of the filename01.tmp file you create. We can possibly learn something by doing this that will lead to an solution.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.