7

I am relatively new to MacOS, previously I used Ubuntu, so some things are quite strange for me. One of such things is that on MacOS we have 2 /usr directories. The 1st is with path /usr and the 2nd is with path /Library/Developer/CommandLineTools/usr. I don't understand what is the difference between them. Could you pls explain it to me?

3
  • 1
    /usr is read-only part of the signed root filesystem. New things can't be conditionally/optionally added to it while running MacOS with full security options enabled, so developer tools that aren't included with the OS itself have to be installed somewhere else. Commented Aug 29, 2023 at 16:31
  • @charlesduffy Xcode installed this directory even before SSV, Homebrew and MacPorts have their own directory hierarchy as well. It’s just a way to install software in a familiar directory structure.
    – nohillside
    Commented Aug 30, 2023 at 4:43
  • Sure -- I'm a nixpkgs maintainer (and for that matter used GNU Stow back in the 90s), so I'm very aware of the concept. That doesn't mean Apple hasn't locked themselves into it (deliberately and for good cause). Commented Aug 30, 2023 at 13:19

2 Answers 2

13

The /Library/Developer/CommandLineTools/usr can be thought of as a seperate /usr folder meant for consumption by the developer command line tools. It contains shared libraries for those tools.

It is similar to how you on Linux could have multiple library folders, such as /lib, /usr/lib, /usr/local/lib, etc. However, on macOS there is a much stronger tradition for having each application be somewhat self-contained and bring along libraries and other resources in its own folder instead of relying on system-wide shared resources.

Also note that on modern macOS versions, certain system folders, including /usr are placed on a read-only, signed system volume. This means that even if the developers had wanted to go against macOS tradition and place the libraries there, that wouldn't have been immediately possible on a standard macOS system.

4
  • 1
    This is correct, but it doesn't explain why this is necessary in modern MacOS releases (think "read-only root volume"). Commented Aug 29, 2023 at 16:32
  • 1
    @CharlesDuffy Well, the developer tools package was structured the same way also before read-only root volumes were a thing, so that's not really the reason. It's just the way it's done on macOS - a different tradition.
    – jksoegaard
    Commented Aug 29, 2023 at 18:00
  • The /Library/Developer/CommandLineTools/usr can be thought of as a seperate /usr folder meant for consumption by the developer command line tools and how is that helpful, as opposed to a paraphrase of Apple's thinking? Commented Aug 29, 2023 at 20:17
  • I don’t understand what your point is here. If you can write a more helpful answer, you’re very much welcome to do so.
    – jksoegaard
    Commented Aug 29, 2023 at 20:56
-1

You can only ever have one directory named usr in the root (/) directory, or within any other directory for that matter -- all names in a directory must be unique.

However you can have a directory named usr in any other (sub)directory anywhere on the system. On my current desktop macos system there are 42 directories named usr, including the one in / (but excluding the ones under user home directories).

The usr name is certainly recognizable and may imply something to those who know something of the traditional hierarchical organization of Unix filesystems, such as what sub-directories might be found within it. However in reality the name doesn't have any special meaning whatsoever to the system itself (unless perhaps it is the one in the root directory).

Typically vendors of software subsystems for Unix-like systems will often supply them in a hierarchy of files that mimic the top-level /usr directory (e.g. in that they contain bin, lib, share, and similar directories with similar or identical purposes) but they can be installed in any subdirectory on the system whatsoever, or even unpacked in the root directory so that their files are merged with those in the system's primary /usr directory.

(Note also there is a group of individuals and contributors at the Linux Foundation who have proposed a so-called "Filesystem Hierarchy Standard", but so far as I know it has not be recognized by any actual standards publishing organization such as IEEE, CSA, ECMA, ANSI, CEN, CENELEC, WWWC, ISO, IEC, etc., nor has it been adopted by any other producers of Unix or Unix-compatible systems, such as Apple or any of the BSDs or Solaris, etc.)

You must log in to answer this question.

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