Apparently you can rename file to ....

If I were insane, how would I rename file to .. or .? Is such a filename even allowed?

Backslash doesn't seem to disable dot's special meaning:

$ mv test \.
mv: `test' and `./test' are the same file
  • 11
    . and .. already exist. And dot does not have a special meaning. – ctrl-alt-delor Aug 5 '14 at 17:48
  • 2
    I wonder if you could create files named . or .. from Windows onto external FAT or NTFS media, then try to mount that into a Unix-based system. Hm... – IQAndreas Aug 5 '14 at 23:30
  • 3
    @IQAndreas nope, Windows uses . and .. about same way (superuser.com/a/571364/330318) as Unix does. (And heck lot of other special names: superuser.com/a/217526/330318) – PTwr Aug 6 '14 at 8:01
  • 2
    @PTwr The windows story is trickier than that. Some special things happen at the file system level / NT API level, some in the Win32 subsystem and some and the shell level. For example the GUID magic from your second link is at the shell level, so you won't see them in a typical command line application. I'm not sure if . and .. actually exist in NTFS and the NT API or if they're only added by the Win32 API. I know that there are several discrepancies between the lower level NT API and Win32, for example Win32 hides several files from the drive root. – CodesInChaos Aug 6 '14 at 8:43
  • @CodesInChaos as far as I know dot/dotdot are virtual instances and are emulated in file system driver, and it was same in old FAT which borrowed (problematic) idea from Unix. As per second link, I admit to not reading it fully before posting. Something like this one would probably be better. (but again, this one lacks full ./.. info) – PTwr Aug 6 '14 at 8:59

.. is not special, it is just that it already exists.

On Unix, Dos and MS-Windows every directory has a directory . it links back to itself, and a directory .. it links to its parent directory (or self if root directory).

If .. and . are special it is only because you can not remove them (actually you can, you just remove the directory that contains them).

Therefore you can not name any (other) file . or ...

However you can create files ..., \, , ..  (note there is a space after the .., but you can hardly see it here, or easily in you directory listing) or any other name you like; The only reserved character is / (Warning — advanced details: and null, null is a special character, not used for anything except to mark the end of things and sometimes as a separator). . has no special meaning: not to file names, kernel or to the shell, it does not need escaping. Actually if a file-name starts with a . then it is special, the file is normally hidden, but still it does not need escaping.


This hidden file behaviour came about in an early implementation of ls where the author wanted to hide . and .., so they wrote code to hide any files starting with a .. Other users noticed this bug/feature and started creating files starting with a . when they wanted the file to be hidden.

Explanation of Linked question

In the question you link to the questioner is trying to move the file to the parent directory .. but ends up renaming to ..., files starting with a dot are by default hidden, that is why they can not find it.

When using mv in the form mv a b

  • If you move to . it is effectively a no operation, but mv treats it as an error.
  • If you move to .. it will move the file to the parent directory.
  • 1
    What do you mean by If you move to . it is effectively a no operation? It is not a "no op" it is an error if you try to move a file from A to B when A and B are the same thing. More practical demonstration of this error is mv foo ../some_dir/foo or mv foo some_subdir/../foo. – Brandin Aug 5 '14 at 18:59
  • 7
    For some definition of 'character', NUL (0x00) is also restricted from use in file and directory names. – user117529 Aug 5 '14 at 21:22
  • 1
    The distinction between reserved character (i.e. / and NUL) and reserved name (i.e. . and ..) could be made clearer. Also it is worth pointing out that . at the start of the name has special meaning only at the application layer and not in the kernel or system call API. – kasperd Aug 6 '14 at 10:01
  • I think your space got lost. – nyuszika7h Aug 6 '14 at 14:50
  • 1
    .. and . are special: you can't move or remove them. But they are not special when moving files to them. – reinierpost Aug 7 '14 at 10:44

You can't rename a file to . or .. because all directories already contain entries for those two names. (Those entries point to directories, and you can't rename a file to a directory.)

mv detects the case where the destination is an existing directory, and interprets it as a request to move the file into that directory (using its current name).

Backslashes have nothing to do with this, because . is not a shell metacharacter. \. and . are the same to bash.


The problem is you're moving a file onto a directory. This is allowed to fail.

I'm going to tell you how it once was.

mkdir used to essentially read this (while I'm writing this in sh, it was really written in C and setuid-root).

mknod d $1
ln -d $1 $1/.
ln -d `dirname $1` $1/..

So as you can see there's not much special about . and .. except for the fact they are created for you by mkdir and already exist. There's code now that says you cannot remove them, but it wasn't always the case.

rmdir used to look like this:

rm -d $1/..
rm -d $1/.
rm -d $1
  • +1 for the history lesson, and adding something not properly covered. – ctrl-alt-delor Aug 7 '14 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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