5

In my home directory, there are two files called ._Desktop and ._Library. They have read and write permissions, but cannot be read, even with root.

What do these files do? Is there any way to modify them?

mmmmmm
  • 30,160
Dan
  • 237
  • 1
  • 9
  • What dos you mean cannot be read? What does ls -l on them show – mmmmmm Jun 01 '16 at 23:20
  • ls -l shows -rwx------, but even sudo cat ._Desktop returns permission denied. – Dan Jun 01 '16 at 23:21
  • ls -l shows more than that – mmmmmm Jun 01 '16 at 23:23
  • @Mark: Is there relevant information in the number of hardlinks, file size, or creation date? – Dan Jun 01 '16 at 23:46
  • No but the user name being your username would be of use – mmmmmm Jun 01 '16 at 23:55
  • @Mark: Oh! The user and group name were both my own. – Dan Jun 02 '16 at 00:03
  • 3
    I was guessing already, but http://apple.stackexchange.com/questions/240340/dock-and-terminal-dont-work-on-systems-with-home-directory-on-different-version gives it away... Is your Home folder not on an HFS+ drive on a Mac? If it's on a networked drive, any file with a resource fork will have an associate dot underscore file. – Tetsujin Jun 02 '16 at 05:44
  • @Tetsujin: My home directory is indeed on an NFS drive that is not HFS+ on the back end. – Dan Jun 02 '16 at 08:25
  • 2
    Then that's why those files exist, they hold data that only HFS+ can hold in a single file. Best to leave them well alone. If you copy the 'real' files back to a Mac, that data will again be merged. I think in most cases they are not absolutely vital (but don't quote me;) - but the Mac is still capable of using them in the split AppleDouble format on a remote volume. afaik, if you delete them, they get regenerated every time the Mac deals with the file. – Tetsujin Jun 02 '16 at 08:33

1 Answers1

5

._ Desktop and ._Library contain extended attributes for these directories. This StackOverflow question describes roughly what generic ._ files are.

if for file foo you have another ._foo, and you're on a Mac, the dot-underscore file is where the file resource fork / metadata is kept.

As to why directories like Desktop or Library would need extended attributes is beyond me, though I would guess it has something to do with appearance and special files.


If these ._ files are appearing on a mounted network filesystem (i.e. NFS) that doesn't use HFS+ on the host server, that is because HFS+ would usually store the information found inside these ._ files along with the file itself. However, since other filesystems do not handle these extended attributes nicely, OS X creates a resource fork that allows your client-side HFS+ filesystem to see extended attributes as if they were part of the file itself.

These files are used in the AppleDouble format which cause the file itself and its pesky counterpart to be merged once the file is taken off the networked filesystem and placed onto a HFS+ filesystem. Deleting these ._file metadata counterparts would usually result in their regeneration the next time OS X processes the file itself.

credit to Tetsujin's comment