Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I found a file in a directory named "." Not the "." indicating the directory but an actual file with content in it. This, as you can imagine is causing all sorts of problems. The problem is I can't figure out how to remove it. How would I remove a file named "." without deleting the entire current directory. Here is a listing just to show you:

drwx------  2 mysql    mysql     36864 Jun 28 14:11 .
drwxrwxr-x  5 mysql    mysql      4096 Jun 26 06:46 ..
-rw-r--r--  1 user1    users      2287 Jun 24 14:32 .
-rw-rw----  1 mysql    mysql        65 Jun 21 21:16 db.opt
-rw-r--r--  1 mysql    mysql         0 Jun 28 14:11 .hidden

You can see the directory (.) but you can also see the file owned by "user1" named "." of file size 2287. How would I remove this? (Running RHEL 4.6).

share|improve this question

migrated from stackoverflow.com Jun 28 '10 at 21:25

This question came from our site for professional and enthusiast programmers.

12  
Last time I saw that, it was a rootkit, and I'd been hacked. –  skaffman Jun 28 '10 at 21:19
    
Wild guess, but rename and then delete? –  Sonny Jun 28 '10 at 21:20
    
@Sonny, he would end up renaming the directory, I think –  klez Jun 28 '10 at 21:21
    
If/When it happens again, look inside the file or directory. Look for hints of a rootkit or a virus or anything. Don't just delete it. –  grawity Jun 29 '10 at 11:55
add comment

9 Answers

up vote 15 down vote accepted

One way is to use the inode number

ls -i

Get the inode number of the bad file, pretend it is 42

find . -inum 42 -exec rm -i {} \;
share|improve this answer
add comment

Double-check that it doesn't have a space with ls -alQ:

drwxr-xr-x  2 adam adam 4096 2010-06-28 14:23 "."
-rw-r--r--  1 adam adam    0 2010-06-28 14:23 ". "
drwxr-xr-x 71 adam adam 4096 2010-06-28 14:23 ".."
share|improve this answer
    
Probably the best sure answer so far. Can probably be followed with "rm -i .\ " (without quotes, note escaped space). –  Platinum Azure Jun 28 '10 at 21:32
add comment
find -user user1 -print
find -user user1 -delete

My guess it's not really called '.'. There is probably a control character or similar. The above removes it based on the owner. The -print is a trial run to avoid surprises.

share|improve this answer
add comment

You could run rm with interactive and confirm only the files you want to delete example:

rm -i ./.
share|improve this answer
add comment

So it turns out it wasn't just a ".". There was a control character in the name (^M). As such, I just did a: rm -i ".^M" (key sequence control-V control-M) and it removed.

share|improve this answer
add comment

Are you sure it's called '.'. It doesn't have any spaces or anything, it's called '. '?

share|improve this answer
add comment

By default, rm does not remove directories, so why not just use

rm -i .
share|improve this answer
    
Yes, when it is just a file, you can directly use rm. –  thegeek Jul 6 '10 at 9:51
add comment

Try ls -il to get the inode number...though I not sure where you go from there. Perhaps bang up a quicky in c to get rid of it.

But if it is part of a rootkit, you need a clean install anyway...

share|improve this answer
add comment

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.