
Nature has its own way to reach out for perfection and the same should be our instinct to make our creations perfect.
Why?
Scenario-1:
Consider an ideal software or package which requires multiple files to function properly.
- Binary files
- Configuration files
- Log files
- Data files
- Metadata files during execution
- Libraries
For now, let’s consider there is just one directory and I am keeping all of the dependent files in that directory.
$ ls
package-1.binary package-1.conf package-1.data package-1.lib package-1.log package-1.tmp
Another software comes in the picture which has its own dependent files.
$ ls
package-1.binary package-1.data package-1.log package-2.binary package-2.data package-2.log
package-1.conf package-1.lib package-1.tmp package-2.conf package-2.lib package-2.tmp
Things will get messy while dealing with various software since handling them won’t be easy and will lead to a chaotic situation.
Scenario-2:
- Binary files –> /dir-1
- Configuration files –> /dir-2
- Log files –> /dir-3
- Data files –> /dir-4
- Meta files –> /dir-5
- Libraries –> /dir-6
As the work gets overloaded I need more admins to support they won’t be able to relate with the naming convention as I did.
To escape this situation the creator of Unix decided to follow a philosophy “Convention over Configuration”.
As the name suggest giving priority to defined convention over individual’s configuration. So that everyone should be on the same page and keeping that in mind everyone else will follow.
And the simulation of the philosophy was like this
- Binary files –> /bin
- Configuration files –> /etc
- Log files –> /log
- Data files –> /var
- Meta files –> /tmp
- Libraries –> /lib
Which resulted in the Unix File Tree
$ tree -d -L 1
.
├── apps
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── lib64
├── lost+found
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── snap
├── srv
├── sys
├── tmp
├── usr
└── var
22 directories
You might be thinking that how will Unix figure out where is the configuration file, where is the binary and rest of the stuff of the software.
Here comes the role of the PATH variable
$ echo $PATH /home/dennis/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
So now we have a proper understanding of why do we need a File Tree.
For diving deep into the significance of each one of the directory stay tuned for Unix File Tree Part-2.
Cheers!