在 Linux 中什么是双点(. .)和单点(.) ?

ls -ai命令显示 ...的 inode 分别与工作目录和父目录相同。

...到底是什么?

它们是真正的文件还是硬链接?但是正如我所知道的,它不允许创建到目录的硬链接。

117588 次浏览

. represents the directory you are in and .. represents the parent directory.

From the dot definition:

This is a short string (i.e., sequence of characters) that is added to the end of the base name (i.e., the main part of the name) of a file or directory in order to indicate the type of file or directory.

On Unix-like operating systems every directory contains, as a minimum, an object represented by a single dot and another represented by two successive dots. The former refers to the directory itself and the latter refers to its parent directory (i.e., the directory that contains it). These items are automatically created in every directory, as can be seen by using the ls command with its -a option (which instructs it to show all of its contents, including hidden items).

They are special name-inode maps which do count as hard-links (they do increase the link-count) though they aren't really hard-links, since, as you said, directories can't have hard-links. Read more here: Hard links and Unix file system nodes (inodes)

They are not hard links. You can more think of it like a shorthand for this directory (.) and parent of this directory (..).

Try to remove or rename . or ... Then you understand why it is not a hard link.

. represents the current directory that you are using and .. represents the parent directory.

Example:

Suppose you are in the directory /etc/mysql and you wanted to move to the parent directory, i.e. /etc/. Then use cd..:

/etc/mysql> cd ..

And if you wanted to set the path of one file in the current directory bash file, use . with file name like this: ./filename