Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Jun 28 '10 at 21:25

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

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
up vote 17 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

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
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

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

rm -i ./.
share|improve this answer

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

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

share|improve this answer

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .