Understanding the /bin, /sbin, /usr/bin, /usr/sbin Split

Finally something really interesting to talk about. If you’ve used UNIX or any of its derivatives, you’ve probably wondered why there’s /bin, /sbin, /usr/bin, /usr/sbin in the file system. You may even have a rationalisation for the existence of each and every one of these directories. The thing is, though – all these rationalisations were thought up after these directories were created. As it turns out, the real reasoning is pretty damn straightforward.

I’ve never made a secret of the fact that I absolutely detest the UNIX directory structure. The names are non-descriptive and often entirely arbitrary, they require a book to properly understand, and everyone seems to have their own ideas about what goes where. And heck, does it show – even among Linux distributions there’s no consistency about what goes where.

It’s a total and utter nightmare that even defiled my beloved BeOS.

Solutions so far tend to be just layers upon layers upon layers to hide the mess of the directory structure. Mac OS X is especially egregious in this regard – open a terminal and check the directory listing at root – it’s an even bigger mess than regular UNIX. Load up a finder window, and you’re looking at an entirely different directory structure.

This is like buying a beautiful car, only to realise the engine is made of cake and rotting brocolli.

Whenever I complained about the UNIX directory structure in the past, I (and those who agreed with me) were always pummelled with explanations on why it makes sense, why it’s best to spread stuff across /bin, /sbin, /usr/bin, /usr/sbin, and so on. The funny thing always was – these explanations were never particularly consistent between each other.

Late last week, I came across a link at HackerNews giving some intriguing insight into how /bin, /sbin, /usr/bin, and /usr/sbin came to be. Many of you will be surprised to learn that no, there is no divine plan behind all this separation.

Back on November 30 2010, David Collier wondered on the BusyBox mailing list why “kill is in /bin and killall in /usr/bin”. He “[doesn’t] have a grip on what might be the logic for that”. Rob Landley replied, and offered an interesting insight into all this.

The issue was that when Ken Thompson and Dennis Ritchie upgraded from a PDP-7 (on which they created UNIX in 1969) to a PDP-11 in 1971, they were confronted with not one 1.5MB hard drive, but two. Amazingly, they now had an insane amount of megabytes (3 of ‘m). The first disk contained the operating system, while the second one contained all the user stuff. This second disk, with all the user stuff, was mounted at /usr (/home was invented later).

Server
Data Center image via Shutterstock

At some point, the operating system grew too big for the first disk, and had to spill over to the second disk. As a result, Thompson and Ritchie replicated the system directory structure (/bin, /sbin, /lib, /tmp, and so on) on this second disk under /usr. When they got a third disk, they moved all the user stuff from /usr to the third disk, mounted under /home.

This forced them to come up with a number of rules, such as that a command like mount couldn’t be installed in /usr/bin, since mount was needed to mount the second disk (/usr) in the first place.

“The /bin vs /usr/bin split (and all the others) is an artifact of this, a 1970’s implementation detail that got carried forward for decades by bureaucrats who never question _why_ they’re doing things,” Landley explains, “It stopped making any sense before Linux was ever invented, for multiple reasons.”

He then continues to details these reasons. First, Linux already has a temporary system that takes care of the ‘this file is needed before that one’-problem. Second, shared libraries solved the issues caused by static linking (which was the norm back when UNIX was created). Third, hard drive space hit the 100MB mark back in 1990, so small disks are no longer an issue.

“Standards bureaucracies like the Linux Foundation (which consumed the Free Standards Group in its ever-growing accretion disk years ago) happily document and add to this sort of complexity without ever trying to understand why it was there in the first place,” he adds, “‘Ken and Dennis leaked their OS into the equivalent of home because an RK05 disk pack on the PDP-11 was too small’ goes whoosh over their heads.”

In a way, this feels like vindication. All those silly rationalisations people are bandying about – they’re all made up after the fact, for reasons that haven’t made sense in at least 30 years – and heck, that never made any sense in the Linux world at all.

Arguing that the UNIX directory structure is a horrible, horrible mess that defiles an otherwise elegant system is like trying to convince a floor tile to flip over. People are so used to their knee-jerk responses about how it all supposedly makes sense, they often refuse to even think about redesigning it for the modern age. Since the geek is a proud and stubborn creature, there’s little to no chance of this ever changing in my lifetime.

“I’m pretty sure the busybox install just puts binaries wherever other versions of those binaries have historically gone. There’s no actual REASON for any of it anymore. Personally, I symlink /bin /sbin and /lib to their /usr equivalents on systems I put together,” Landley, currently working on embedded Linux, concludes, “Embedded guys try to understand and simplify…”

135 Comments

  1. 2012-01-30 8:55 pm
    • 2012-01-30 9:13 pm
      • 2012-01-30 9:18 pm
        • 2012-01-30 9:24 pm
          • 2012-01-31 9:10 am
          • 2012-01-31 3:27 pm
          • 2012-01-31 9:57 pm
          • 2012-02-01 5:50 pm
        • 2012-01-30 9:33 pm
        • 2012-01-30 9:48 pm
          • 2012-01-30 9:50 pm
          • 2012-01-31 4:48 pm
          • 2012-02-02 4:51 am
          • 2012-01-31 9:11 pm
          • 2012-01-30 11:15 pm
          • 2012-01-31 1:21 am
          • 2012-01-31 1:22 am
          • 2012-01-31 2:39 pm
          • 2012-01-31 4:36 pm
          • 2012-01-31 6:35 pm
          • 2012-02-01 11:57 am
          • 2012-01-31 1:19 am
          • 2012-01-31 7:01 am
        • 2012-01-31 4:05 am
        • 2012-01-31 2:53 pm
        • 2012-02-01 5:38 pm
  2. 2012-01-30 9:05 pm
    • 2012-01-30 9:21 pm
      • 2012-01-30 9:31 pm
        • 2012-01-30 10:59 pm
          • 2012-01-30 11:22 pm
          • 2012-01-30 11:26 pm
          • 2012-01-31 1:12 am
          • 2012-01-31 9:17 am
      • 2012-01-30 10:44 pm
    • 2012-01-31 1:25 am
      • 2012-01-31 3:34 am
        • 2012-01-31 8:33 pm
    • 2012-01-31 11:53 am
    • 2012-02-01 4:52 am
  3. 2012-01-30 9:07 pm
    • 2012-01-30 11:09 pm
      • 2012-01-31 12:15 am
        • 2012-01-31 11:51 am
      • 2012-02-01 4:55 am
    • 2012-01-31 1:35 am
  4. 2012-01-30 9:16 pm
    • 2012-01-30 9:28 pm
      • 2012-01-30 9:32 pm
        • 2012-01-30 9:40 pm
          • 2012-01-30 9:54 pm
          • 2012-01-30 10:06 pm
          • 2012-01-30 11:21 pm
          • 2012-01-31 5:57 pm
    • 2012-01-30 9:30 pm
      • 2012-01-30 11:56 pm
      • 2012-01-31 8:17 am
      • 2012-01-31 12:09 pm
        • 2012-01-31 5:59 pm
          • 2012-01-31 6:07 pm
          • 2012-01-31 6:19 pm
      • 2012-01-31 9:16 pm
  5. 2012-01-30 9:21 pm
    • 2012-01-30 9:26 pm
      • 2012-01-30 9:33 pm
  6. 2012-01-30 9:22 pm
  7. 2012-01-30 9:25 pm
  8. 2012-01-30 9:46 pm
    • 2012-01-30 10:19 pm
  9. 2012-01-30 10:19 pm
    • 2012-01-30 10:55 pm
      • 2012-01-31 12:14 pm
        • 2012-01-31 1:26 pm
          • 2012-01-31 2:04 pm
          • 2012-01-31 8:49 pm
          • 2012-02-01 9:56 pm
  10. 2012-01-30 10:30 pm
  11. 2012-01-30 10:43 pm
    • 2012-01-30 11:33 pm
    • 2012-01-31 4:03 am
  12. 2012-01-30 10:52 pm
  13. 2012-01-30 11:23 pm
    • 2012-01-30 11:40 pm
    • 2012-01-31 7:04 am
  14. 2012-01-31 12:20 am
  15. 2012-01-31 1:02 am
  16. 2012-01-31 1:31 am
  17. 2012-01-31 4:41 am
  18. 2012-01-31 6:40 am
    • 2012-01-31 7:03 am
  19. 2012-01-31 9:12 am
    • 2012-01-31 1:33 pm
  20. 2012-01-31 9:27 am
  21. 2012-01-31 10:48 am
    • 2012-01-31 11:30 am
      • 2012-01-31 1:17 pm
      • 2012-01-31 6:15 pm
  22. 2012-01-31 12:14 pm
    • 2012-01-31 9:19 pm
      • 2012-02-01 11:26 am
        • 2012-02-01 5:26 pm
          • 2012-02-01 8:11 pm
          • 2012-02-02 4:00 am
          • 2012-02-02 8:10 am
          • 2012-02-02 8:36 am
          • 2012-02-02 10:06 am
          • 2012-02-02 3:17 pm
          • 2012-02-02 5:48 pm
          • 2012-02-02 11:37 pm
  23. 2012-01-31 1:14 pm
  24. 2012-01-31 8:14 pm
    • 2012-01-31 9:34 pm
  25. 2012-01-31 8:53 pm
  26. 2012-01-31 9:09 pm
  27. 2012-02-01 12:33 pm
    • 2012-02-01 1:44 pm
      • 2012-02-01 7:21 pm
        • 2012-02-01 10:13 pm
          • 2012-02-02 12:16 pm
          • 2012-02-02 1:20 pm
          • 2012-02-03 12:27 pm
          • 2012-02-03 1:21 pm
          • 2012-02-03 2:20 pm
          • 2012-02-03 10:58 pm
          • 2012-02-04 4:29 am
          • 2012-02-03 2:35 pm
          • 2012-02-03 2:47 pm
          • 2012-02-03 3:09 pm
          • 2012-02-03 10:55 pm
          • 2012-02-04 4:44 am
        • 2012-02-03 10:36 pm
    • 2012-02-01 4:58 pm
      • 2012-02-01 7:22 pm
        • 2012-02-01 8:52 pm