5

Is this file important to me? I want to delete this file since it's zero bytes. But I have tried sudo rm .file, sudo rm -f .file, sudo chmod -R 777 .file all failed. Any idea?

5
  • @user3439894: I'm willing to learn. Could you provide more resources about this file/the idea behind it? Oh, so I would almost destroy my system if I would actually delete it?
    – Raining
    Nov 14 '21 at 3:02
  • 1
    @user3439894: Thanks! I think your words deserve my answer points.
    – Raining
    Nov 14 '21 at 8:39
  • Off-topic: I really like the colors and design of the output in your screenshot. How did you get it? Is it a special terminal or ls command? Nov 14 '21 at 15:46
  • 1
    @EricDuminil: Alacritty (special terminal) and exa (ls command).
    – Raining
    Nov 15 '21 at 1:23
  • Excellent, thanks. I adopted exa. It looks great. Nov 15 '21 at 11:33
4

There's absolutely no reason to delete the file. Note that the file does not take up space on your drive.

The file is not a usual file put there by some program, you've installed. It is part of the operating system, and comes with the macOS installation. It is not meant to be removed.

The file is there to support the operating system feature known as "file reference URLs":

Normally, you know files by their name and folder placement - for example ~/Documents/Letter.docx.

However it is also possible to reference the exact same file by way of this special file, you're concerned about. The same file could be referenced by something similar to /.file/id=123.45. This is in many ways similar to using the /.vol special file which is part of volfs (accessing files by volume number and inode), and similar to referencing files by their inode number alone (only valid on the same file system).

The advantage of this is that a running application can be given a specific file as a normal path/filename, and then reference it by a file reference URL such as for example file:///.file/id=123.45. This means that even if the user decides to rename or move the file in the file system, the application can still open and access it without knowing about those changes. This is something that typically comes into play when the user drags and drops files on applications.

Note that the file reference URL is a non-persistent reference - meaning that if you unmount that part of the file system, or if you reboot the computer, the URL becomes invalid.

2
  • Now that I have given you the key words, you should be able to google "file reference URL"
    – jksoegaard
    Nov 14 '21 at 14:46
  • Wow! I'm glad that I didn't (and cannot) delete this file. It's so cool and powerful.
    – Raining
    Nov 14 '21 at 14:52

You must log in to answer this question.

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