Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Last night I had a Dovecot server lock up and it corrupted a file in a user's maildir. The file name now has special characters in it and can't be deleted, all command line tools say the file cannot be found, even though it shows up via the LS command.

1386141318.M854059PΈ3Ώ62.email.vantagetitle.com,S?11304,W11473:2,Sc

You can see the special characters in the name such as "Ώ" or "Έ".

I can't seem to find any way to remove this file.

should I do an fsck?

EDIT 1:

I ended up making a new "cur" directory and moved all of the good emails over to it. I renamed the old "cur" directory to "bad cur"

I have tried the following...

sh-3.2# rm -rf badcur
rm: badcur: Directory not empty
sh-3.2# cd badcur
sh-3.2# ls
1386141318.M854059PΈ3Ώ62.email.vantagetitle.com,S?11304,W?11473:2,Sbc
sh-3.2# rm -rf 1386141318.M854059PΈ3Ώ62.email.vantagetitle.com,S?11304,W?11473:2,Sbc
sh-3.2# ls
1386141318.M854059PΈ3Ώ62.email.vantagetitle.com,S?11304,W?11473:2,Sbc
sh-3.2# ls -i
ls: 1386141318.M854059PΈ3Ώ62.email.vantagetitle.com,S?11304,W11473:2,Sbc: No such file or directory
sh-3.2#  
share|improve this question
    
Have you tried autocompletion of the file name in a shell? –  Kl4m Jan 8 at 17:42
    
Yes, it will just return no such file or directory –  TriadicTech Jan 8 at 18:02
    
Try to use quotes and \ in front of the special characters. –  jeffatrackaid Jan 8 at 18:45

4 Answers 4

You could try using -i which will present you with a question

rm -i 1386141318.M854059P*
rm: remove regular file '1386141318.M854059PΈ3Ώ62.email.vantagetitle.com,S?11304,W11473:2,Sc'?

and answer y


You may be able to delete the file using it's inode number. use ls -li to get the inode number of the file. Once you have it, use find to delete it

find . -inum <inode number> -delete
share|improve this answer
    
I tried that, ls will just return ls: 1386141318.M854059PΈ3Ώ62.email.vantagetitle.com,S?11304,W11473:2,Sbc: No such file or directory –  TriadicTech Jan 8 at 17:55
    
@Potenza: This has worked for me in the past. See my update for using find. –  Iain Jan 8 at 18:05
    
delete by inode usually works when all else fails. –  Matt Jan 8 at 21:39
    
ls -li returns no such file or directory. As if it sees the file but then decides it doesn't exist. a normal ls works fine but doesn't show the inode. –  TriadicTech Jan 9 at 20:19

The easiest way to tackle these is to use a double-dash (--) following the rm.

# rm -- 1386141318.M854059P*

The double-dash tells the command rm that you are done passing command switches and what follows is what its supposed to operate on.

-Scott

share|improve this answer
    
a double dash ends generally help with file names starting with a - character, so they don't get interpreted as arguments –  mtm Jan 8 at 21:41

If present, you could browse the directory with Midnight Commander.

Enter mc, use the arrow keys to select the file and then hit F8 to delete it

share|improve this answer

Sounds broken, unmount the file system and run the correct version of fsck for your file system.

Probably fsck.ext3 /dev/sdaN

Run a df . in the directory if you don't know which file system your on.

Run mount if you don't know the correct type of the file system.

share|improve this answer
    
The way rm -rf fails on that particular directory has me absolutely convinced the file system is corrupted. In theory it could be only some cached metadata, which is corrupted, in which case a reboot would fix it. But more likely an fsck is needed. The fsck should not be done with the file system mounted. If it is the root file system, the fsck can be done during boot. Console access may be needed during boot, if an automated fsck fails. –  kasperd May 17 at 7:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.