Beginners of Unix (including Linux) are often confused and don't understand what the directory structure means.
For example, there is a subdirectory/bin underneath the root directory that holds the binaries. However, the/USR subdirectory also contains/usr/bin, as well as/usr/local/bin, which is also used to store binaries, and some systems even have/opt/bin. What's the difference between them?
For a long time, I have been puzzled, I do not understand why this design. Like most people, I just memorize different catalogs according to the UNIX File system architecture standard (filesystem hierarchy Standard).
Yesterday, I read the short explanation of Rob Landley, and it dawned on me that the UNIX directory structure was historically caused.
In 1969, Ken Thompson and Dennis Ritchie invented Unix on a minicomputer PDP-7. 1971, they upgraded the mainframe to PDP-11.
At the time, they used a storage disk called RK05, which was about 1.5MB in size.
It was not long before the operating system (the root directory) became bigger and larger, and a disk was not installed. As a result, they added a second set of RK05, and the first disk dedicated to the system program, the second disk dedicated to the user's own program, so the mount directory point named/usr.
In other words, the root directory "/" is mounted on the first disk, and the "/usr" directory is mounted on the second disk. In addition, the directory structure of the two disks is identical, the directory of the first disk (/bin,/sbin,/lib,/tmp ...) Are again appearing in the/usr directory.
Later, the second plate was full, and they had to add a third set of RK05, the Mount directory point named/home, and specified/USR used to store the user's program,/home to store the user's data.
Since then, this directory structure has continued. As the size of the hard disk becomes larger, the meaning of each directory is further clarified.
/: Storage System programs, that is, At&t developed UNIX programs.
/USR: store programs developed by UNIX system vendors, such as IBM and HP.
/usr/local: Store the user's own installed programs.
/OPT: In some systems, it is used to store programs developed by Third-party vendors, so it is named option, meaning "optional".