Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
671 views
in Technique[技术] by (71.8m points)

macos - what does mac os /Library folder store?

I am a new to mac osx. One thing confusing me is what does /Library or /System/Library folders store? As its name meaning, I thought is should be something like /lib or /usr/lib in Linux. However, it does not. Inside it, it looks more similar to application bundles. And all naming is very application-specific, like /Library/iChat. If they are application-specific, then why they are called Library? Usually when named as Library, it is for codes or resources sharing purpose.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The library folders store settings, resources, and support files. There up to 6 "levels" of them:

  • The user library, ~/Library, stores per-user settings etc.
  • The local library, /Library, stores computer-wide settings etc. BTW, I call this the "local" library, because in NextStep it was /Local/Library, but you'll see all sorts of other names for it, such as the root library, computer library, ...
  • The network library, /Network/Library would store settings shared by all computers in a network domain -- if a network domain admin set one up, which nobody does anymore
  • The system library, /System/Library, stores the base settings, resources, etc that come with OS X. In theory, you shouldn't change anything in here.

Sandboxed apps don't have access to most of the user's home folder. They're mostly restricted to their own sandbox "container" (which is itself inside the user library), and as a result they get their own "private" libraries:

  • Per-application sandbox libraries, ~/Library/Containers/<application-ID>/Data/Library, which will generally contain a few real folders like Preferences and Saved Application State, and also symbolic links to the regular-user-library versions of other folders (e.g. Fonts).
  • Application group sandbox libraries, ~/Library/Group Containers/<application-group-ID>/Library, is used to store shared preferences, application support files, caches, etc between related groups of applications (from the same developer).

Now, as for the files inside the various library folders: Most of them are organized by type (e.g. there's a Preferences folder, a Caches folder, an Application Support folder, etc) with files/subfolders per application (or system component, or whatever). Some resource types are available to many or all programs (e.g. Fonts, Keychains, Services), so there's just a bunch of files there. However, some programs (mostly Apple-authored ones) are, um, egotistical enough to think they need their own top-level folder inside the library, so they go ahead and create one and store things in it.

As for the name "Library", I wouldn't read too much into it. It's basically a place to store things that programs need to get at, but that the user doesn't (generally) need to be explicitly aware of. Basically, things that the user never needs to double-click or use an open/save dialog to access. When you run Mail.app, you don't need to tell it to use the settings in ~/Library/Preferences/com.apple.mail.plist, or the cached mailbox contents in ~/Library/Mail, or the state information in ~/Library/Saved Application State/com.apple.mail.savedState.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...