為什麼一些windows檔案和資料夾名稱前面有一個點?

雖然我們大多數人在Windows系統上只看到普通的檔名和資料夾名,但其他人可能遇到了更出乎意料的事情——前面有一個點的檔名和資料夾名。為什麼會這樣?今天的超級使用者問答帖子回答了一位非常好奇的讀者的問題。...

為什麼一些windows檔案和資料夾名稱前面有一個點?

雖然我們大多數人在Windows系統上只看到普通的檔名和資料夾名,但其他人可能遇到了更出乎意料的事情——前面有一個點的檔名和資料夾名。為什麼會這樣?今天的超級使用者問答帖子回答了一位非常好奇的讀者的問題。

今天的問答環節是由SuperUser提供的,SuperUser是Stack Exchange的一個分支,是一個由社群驅動的問答網站分組。

照片由Domiriel(Flickr)提供。

問題

超級使用者讀者Niko Bellic想知道為什麼某些Windows檔案和資料夾名稱前面有一個點:

For example, in the My Documents directory on my Windows system I have found the following folders:

  • .ssh
  • .subversion

Is this some sort of naming convention that I am unaware of?

為什麼一些Windows檔案和資料夾名稱前面有一個點?

答案

超級使用者貢獻者grawity為我們提供了答案:

This naming convention comes from Unix-like operating systems (such as Linux or OSX) where it means a hidden file or directory. It works anywhere, but its primary use is to hide configuration files in your home directory (i.e. ~/.cache/ or ~/.plan) They are frequently called dot files.

Dot files could, in a way, be called the traditional Unix equivalent to the AppData directory on Windows. Meanwhile, many Linux programs are being changed to follow the XDG base directory specification, moving their configuration to ~/.config/ and other data to ~/.cache/ and ~/.local/share/. This makes it more similar to AppData\Roaming and AppData\Local.

You have these .ssh and .subversion directories on Windows because you have used some programs (specifically, OpenSSH and Subversion) that have been ported to use Windows system APIs rather than POSIX ones, but have not been adjusted for some other Windows conventi***.

Sometimes this adaptation is skipped intentionally to make life easier for people who use Unix-like environments such as Cygwin on their Windows systems. For example, Cygwin installs the standard set of Unix-like tools like ls, which ignores the Windows hidden flag and only honors the dot file names. It is also easier to synchronize configurati*** between an individual’s Windows and Linux/BSD/OSX computers if it is shared in the same location.

These files are typically found in the user’s home directory (i.e. /home/name/.ssh on Linux or C:\Users\name\.ssh on Windows 7 and later). It is quite rare for them to be put in the Documents or My Documents subdirectories (they do not contain documents after all).

As Rob Pike writes on Google+, this was an accidental feature:

Long ago, as the design of the Unix file system was being worked out, the entries . and .. appeared in order to make navigation easier. I am not sure, but I believe .. went in during Version 2’s rewrite when the file system became hierarchical (it had a very different structure early on). When one typed ls, however, these files appeared, so either Ken or Dennis added a simple test to the program. It was in assembler then, but the code in question was equivalent to something like this:

  • if (name[0] == ‘.’) continue;

This statement was a little shorter than what it should have been, which is:

  • if (strcmp(name, “.”) == 0 || strcmp(name, “..”) == 0) continue;

But hey, it was easy and two things resulted.

First, a bad precedent was set. A lot of other lazy programmers introduced bugs by making the same simplification. Actual files beginning with periods are often skipped when they should be counted.

Second, and much worse, the idea of a hidden or dot file was created. As a c***equence, more lazy programmers started dropping files into everyone’s home directory. I do not have much software installed on the computer I am using to type this, but my home directory has about one hundred dot files and I do not even know what most of them are or whether they are still needed. Every file name evaluation that goes through my home directory is slowed down by this accumulated sludge.


有什麼要補充的解釋嗎?在評論中發出聲音。想從其他精通技術的Stack Exchange使用者那裡瞭解更多答案嗎?在這裡檢視完整的討論主題。

  • 發表於 2021-04-10 04:29
  • 閱讀 ( 36 )
  • 分類:網際網路

你可能感興趣的文章

刪除這些windows檔案和資料夾以釋放磁碟空間

...安全地刪除以釋放磁碟空間的Windows檔案和資料夾,以及為什麼要刪除它們。請注意,其中一些資料夾位於受保護的位置,因此刪除它們時要小心。 ...

  • 發佈於 2021-03-11 09:22
  • 閲讀 ( 51 )

如何在ubuntu中加密檔案和資料夾

... 在Linux上,您使用什麼方法加密檔案和資料夾?你找到我們沒提到的其他工具了嗎? ...

  • 發佈於 2021-03-11 16:31
  • 閲讀 ( 58 )

使用別名、標籤等減少查詢程式混亂和mac垃圾

...果你從來沒有在macfinder中檢視過Recents部分的混亂內容,為什麼要在側邊欄中顯示它的連結呢?從Finder>Preferences>側邊欄中刪除它(取消選中最近的複選框)。 ...

  • 發佈於 2021-03-12 04:07
  • 閲讀 ( 45 )

在Windows7中隱藏資料夾的3種簡便快捷的方法

...將敏感資訊或私人檔案儲存在安全的地方。本文總結了在Windows7中隱藏資料夾的三種簡單快捷的方法。 ...

  • 發佈於 2021-03-12 13:49
  • 閲讀 ( 36 )

如何對mac上的檔案和資料夾進行密碼保護

我們在電腦上儲存了大量的資料,其中一些是私人的和敏感的。透過使用FileVault加密整個硬碟驅動器,可以保護Mac上的所有檔案。 ...

  • 發佈於 2021-03-14 01:15
  • 閲讀 ( 49 )

7個你永遠無法理解的windows謎團

... 讓我們來看看這些謎團。你可能想知道為什麼窗戶在某些地方很特別,或者根本沒有注意到它們。下面是你日常作業系統中一些神祕的小元素的答案。 ...

  • 發佈於 2021-03-14 02:33
  • 閲讀 ( 68 )

使用xampp在windows上免費託管和編輯網站

你想建立一個網站,但不知道從哪裡開始? ...

  • 發佈於 2021-03-14 07:36
  • 閲讀 ( 41 )

使用這些工具自定義windows右鍵單擊選單

...程式設計的傢伙,我們可以在電腦上工作或瀏覽的時候取一些。在MakeUseOf,我們已經研究了一些為右擊選單新增更多功能的方法。 ...

  • 發佈於 2021-03-16 06:25
  • 閲讀 ( 51 )

什麼是快捷病毒,你如何去除它?

... 那麼究竟什麼是捷徑病毒呢?為什麼這麼糟糕?如果你被感染了,你怎麼去除一個呢? ...

  • 發佈於 2021-03-17 17:02
  • 閲讀 ( 60 )

如何在mac和windows之間輕鬆共享檔案

...本機工具輕鬆地進行Mac到Windows的檔案傳輸。另外,還有一些第三方解決方案值得一看。 ...

  • 發佈於 2021-03-18 03:08
  • 閲讀 ( 57 )