Why have symbolic links between files in folders at same depth? I noticed that in macOS, the /usr/local/Cellar folder contains binaries installed using Homebrew, and that /usr/local/opt has symbolic links to a bunch of those binaries. I haven't used symbolic links much, but as I understand it, the purpose of them is to create a link in a convenient location to a file/folder that acts as a copy of that file/folder, without having to move that file/folder from its original location.

So my questions are:


Am I correct in my understanding of symbolic links there?
If so, why would you create symbolic links in one folder (/usr/local/opt) to binaries in another folder (/usr/local/Cellar) that is at a similar location/depth in the file structure? Under what circumstances would you use these symbolic links where you couldn't just use the binaries?
Am I correct in my understanding of symbolic links there?


Yes. Symbolic link, as the name implies acts as a link to a file/folder located elsewhere. Accessing the link is generally equivalent to accessing the file/folder.


  If so, why would you create symbolic links in one folder (/usr/local/opt) to binaries in another folder (/usr/local/Cellar) that is at a similar location/depth in the file structure?


If you'll carefully observer in this particular case, the binaries corresponding to all the various installed formulae are in different folders. There's a separate folder corresponding to each installed formula under /usr/local/Cellar. Within the folder for formula is a folder containing version number, followed by installed files for the formula.

Via symlink under /usr/local/opt, the installation location for all the formula are brought in one place.

For knowing the exact purpose of why /usr/local/opt folder is created by Homebrew, you can refer to this post on Stack Overflow:


https://stackoverflow.com/questions/35337601/why-is-there-a-usr-local-opt-directory-created-by-homebrew-and-should-i-use-it