macOS – Introduction to System Directory Conventions

filesystemmacos

I'm using macs since 8 years now and have a computer science background.
I know, that when installing software, OSX is not as nasty as windows.
Meaning, instead of dealing with dll libraries and stuff that is installed somewhere in the system, apps in osx usually – by convention – should only use folders like "Application Support" and "Preferences" for their stuff.

Since, there are apps, that don't follow conventions I'd like to know, what structure is encouraged by the system and what not. So I can know for example which folders in ~/Library/ I can delete without sacrificing system stability.

For example in my user-lib folder I had stuff like "MonoAndroid" from which I know where they came from (xamarin) and from which I know whether I want to delete them, because I'm not using the app assosiated with that anymore.

I suppose that the user directories are not that of a big problem with deleting stuff, but there is always this one app, that keeps files also in higher dir's (like said xamarin).

Additionally, I want to clean up a friend's mac, and since I was not using that, I'd like to have and intuition of "what belongs where" and what not.

Is there a guide or something?
Or a good documentation about where stuff should go and which folders should not been touched? I searched for that, but did not find anything good, really.
Until now I have based my knowledge about osx on knowledge about unix and half knowledge from usage.

Best Answer

Unix knowledge will help a lot as long as it is not following Linux or other conventions exactly (Linux is Unix like whilst OSX is a Unix based on BSD)

Some description is given by Apple in this developer documentation (The link does not seem to be exact but look for the OSX part not IOS) There are several sections which are too long to list here.

One is for UNIX-specific directories but I am surprised to see "/usr—Contains non-essential command-line binaries, libraries, header files, and other data." They might be non-essential but removing this will break a lot - you should only change things in /usr/local

Another is The Library Directory Stores App-Specific Files The main sections are

  • Application Support - app data files except those associated with the user’s documents
  • Caches - app-specific support files that your app can re-create easily.
  • Frameworks - frameworks that must be shared by multiple apps
  • Preferences - app-specific preference files used the NSUserDefaults class or CFPreferences API

Treat this as a guide as many (Most?) apps do not follow this 100%.

Mono has in the past put things in the wrong place e.g. in /usr/bin Other apps use Preferences not via the API. Other apps use directories in ~/Library itself e.g. Mail.app