Undeletable file in RedHat Linux

2

There is a file under my home area that I cannot delete. When I do an ls -al on the directory, the permissions are ?--------- and there is a ? for user, group, size and date columns. When I attempt to remove it, I get the following error from rm: rm: cannot remove 'file': Invalid argument

Any ideas on a method to remove such an odd file?

steveo225

Posted 2013-01-23T20:56:07.220

Reputation: 287

Is it open in another process? – None – 2013-01-23T20:58:26.260

Could you show the output of ls -l on the file? What is your filesystem? – terdon – 2013-01-23T20:59:53.777

@JeffreyLin No process is using it – steveo225 – 2013-01-23T21:10:39.563

@terdon I mentioned the output of ls -l in the question, I had to use a as well because it is hidden. The filesystem is nfs (surprisingly). If I have access to the server it is mounted from I am going to try and delete it there instead. – steveo225 – 2013-01-23T21:12:25.740

I wanted the entire output of ls to see if there were any weird characters or encoding issues with the file name (which is not in your question). I have sometimes seen strange things like this when using filenames in greek on a file system that was not UTF8 encoded. In any case, if it is an nfs share it may well be a corruption in the sharing process. Either go to the server or remount it, that might help. – terdon – 2013-01-23T21:16:17.143

@terdon No weird characters, only a-f0-9.. It has been remounted since I first noticed the file. – steveo225 – 2013-01-23T21:19:06.720

When you look at the file locally (on the NFS server), does it show the same ownerships/permissions? If it does it's quite likely a case of file-system corruption on the underlying FS rather than an NFS thing. – tink – 2013-01-24T01:09:10.697

@terdon: Funny characters in the file name aren’t likely to be the issue –– if steveo were not typing the file name correctly, rm would say “No such file or directory” rather than “Invalid argument” (which is what steveo reported seeing). – Scott – 2013-01-25T01:05:48.213

I’m surprised that no one has commented on the fact that the ls –l output says ?--------- rather than ---------- (or brw------- or prw-r--r-- or anything else normal).  I believe that this is screaming, “This file is not of any known file type”; i.e., the filesystem is corrupt.  This probably requires filesystem repair tools.  steveo: have you rebooted?  Have you run fsck? – Scott – 2013-01-25T01:06:40.803

Yes, server has been rebooted. However, I do not know about the server hosting the file system. I haven't gotten access to it just yet. – steveo225 – 2013-01-25T01:43:31.387

Answers

1

If the file is on NFS , you will have to login to the server that is serving the filesystem (the file must be local to the server ), then you can run.

lsof | grep -i filename

It should list any processes that are using the file, you can then close the program (if someone on the network has the file open I think there will be an nfsd process listed against the file). Once all processes are closed you should be able to remove the file as necessary either local or remote. If that doesn't work you should be able to rm -rf from the server to force delete it.

user192032

Posted 2013-01-23T20:56:07.220

Reputation:

1Even better: lsof filename – Matthew Lundberg – 2013-01-24T01:43:18.657

Once I got access to the server. I was able to remove it. Unfortunately, due to my zealousness to remove it, I forgot to check the state of the file on the local system first. Would have been interesting to see if there was a clue to the problem. – steveo225 – 2013-01-26T03:38:45.420