{"id":144,"date":"2019-07-16T09:17:00","date_gmt":"2019-07-16T03:47:00","guid":{"rendered":"https:\/\/opstree.com\/blog\/\/?p=144"},"modified":"2019-08-29T18:17:41","modified_gmt":"2019-08-29T12:47:41","slug":"unix-file-tree-part-1","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2019\/07\/16\/unix-file-tree-part-1\/","title":{"rendered":"Unix File Tree Part-1"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align:left;\">\n<div class=\"separator\" style=\"clear:both;text-align:center;\"><img decoding=\"async\" class=\"irc_mi\" style=\"margin-top:0;\" src=\"https:\/\/weecnetwork.org\/wn\/wp-content\/uploads\/2019\/01\/why-raising-and-lifting...-header-photo.jpg\" alt=\"Related image\"><\/div>\n<p>Nature has its own way to reach out for perfection and the same should be our instinct to make our creations perfect.<\/p>\n<div class=\"Z0LcW AZCkJd\">Dennis Ritchie,&nbsp;<span class=\"ILfuVd NA6bn c3biWd\"><span class=\"e24Kjd\">father of&nbsp;<b>Unix<\/b>&nbsp;and an esteemed computer scientist<\/span><\/span>&nbsp;might have implied the same approach for Unix directory structure.<p><\/p>\n<p><b>Why?<\/b><\/p><\/div>\n<div>Before getting into the hierarchy of&nbsp;<i>Unix File Tree<\/i>&nbsp;lets discuss why we need it. The need for a directory structure arises when multiple users are handling multiple software along with their dependent files. Let me explain this with a couple of scenarios.<p><\/p>\n<p><strong>Scenario-1:<\/strong><\/p><\/div>\n<p>Consider an ideal software or package which requires multiple files to function properly.<\/p>\n<ul>\n<li>Binary files<\/li>\n<li>Configuration files<\/li>\n<li>Log files<\/li>\n<li>Data files<\/li>\n<li>Metadata files during execution<\/li>\n<li>Libraries<\/li>\n<\/ul>\n<p>&nbsp;For now, let&#8217;s consider there is just one directory and I am keeping all of the dependent files in that directory.&nbsp;<\/p>\n<pre><span class=\"pl-k\">$ ls\npackage-1.binary  package-1.conf  package-1.data  package-1.lib  package-1.log  package-1.tmp<\/span>\n<\/pre>\n<p>Another software comes in the picture which has its own dependent files.<\/p>\n<pre><span class=\"pl-k\">$ ls\npackage-1.binary  package-1.data  package-1.log  package-2.binary  package-2.data  package-2.log\npackage-1.conf    package-1.lib   package-1.tmp  package-2.conf    package-2.lib   package-2.tmp<\/span><\/pre>\n<p>Things will get messy while dealing with various software<span id=\"gmail-92\" class=\"gmail-gr_ gmail-gr_92 gmail-gr-alert gmail-gr_gramm gmail-gr_inline_cards gmail-gr_run_anim gmail-Punctuation gmail-only-del gmail-replaceWithoutSep\">&nbsp;<\/span>since handling them won&#8217;t be easy and will lead to a chaotic situation.<\/p>\n<p><strong>Scenario-2:<\/strong><\/p>\n<div>Suppose I am a system admin and managing all of the software in the above scenario-1. To make things organized I created different directories to place the dependent files.<\/div>\n<ul>\n<li>Binary files &#8211;&gt; \/dir-1<\/li>\n<li>Configuration files &#8211;&gt; \/dir-2<\/li>\n<li>Log files &#8211;&gt; \/dir-3<\/li>\n<li>Data files &#8211;&gt; \/dir-4<\/li>\n<li>Meta files &#8211;&gt; \/dir-5<\/li>\n<li>Libraries &#8211;&gt; \/dir-6<\/li>\n<\/ul>\n<p>As the work gets overloaded I need more admins to support they won&#8217;t be able to relate with the naming convention as I did.<br>To escape this situation the creator of Unix decided to follow a philosophy&nbsp;<i><b>&#8220;Convention over Configuration&#8221;.<\/b><\/i><br><i><b>&nbsp;<\/b><\/i>As the name suggest giving priority to defined convention over individual&#8217;s configuration. So that everyone should be on the same page and keeping that in mind everyone else will follow.<br>And the simulation of the philosophy was like this<\/p>\n<ul>\n<li>Binary files &#8211;&gt; \/bin<\/li>\n<li>Configuration files &#8211;&gt; \/etc<\/li>\n<li>Log files &#8211;&gt; \/log<\/li>\n<li>Data files &#8211;&gt; \/var<\/li>\n<li>Meta files &#8211;&gt; \/tmp<\/li>\n<li>Libraries &#8211;&gt; \/lib<\/li>\n<\/ul>\n<p>Which resulted in the Unix File Tree<\/p>\n<pre><span class=\"pl-k\">$ tree -d -L 1\n.\n\u251c\u2500\u2500 apps\n\u251c\u2500\u2500 bin\n\u251c\u2500\u2500 boot\n\u251c\u2500\u2500 dev\n\u251c\u2500\u2500 etc\n\u251c\u2500\u2500 home\n\u251c\u2500\u2500 lib\n\u251c\u2500\u2500 lib64\n\u251c\u2500\u2500 lost+found\n\u251c\u2500\u2500 media\n\u251c\u2500\u2500 mnt\n\u251c\u2500\u2500 opt\n\u251c\u2500\u2500 proc\n\u251c\u2500\u2500 root\n\u251c\u2500\u2500 run\n\u251c\u2500\u2500 sbin\n\u251c\u2500\u2500 snap\n\u251c\u2500\u2500 srv\n\u251c\u2500\u2500 sys\n\u251c\u2500\u2500 tmp\n\u251c\u2500\u2500 usr\n\u2514\u2500\u2500 var\n\n22 directories\n<\/span>\n<\/pre>\n<p>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.<br>Here comes the role of the PATH variable<\/p>\n<pre><span class=\"pl-k\">\n$ echo $PATH\n\/home\/<\/span><span class=\"pl-k\">dennis\/.local\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:\/usr\/games:\/usr\/local\/games:\/snap\/bin\n<\/span><\/pre>\n<div>These are environment variables specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting.<p><\/p>\n<p>So now we have a proper understanding of why do we need a File Tree.<br>For diving deep into the significance of each one of the directory stay tuned for Unix File Tree Part-2.<\/p>\n<p>Cheers!<\/p><\/div>\n<p><\/p>\n<p><img id=\"hzDownscaled\" style=\"position:absolute;top:-10000px;\"><img id=\"hzDownscaled\" style=\"position:absolute;top:-10000px;\"><\/p>\n<\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nature has its own way to reach out for perfection and the same should be our instinct to make our creations perfect. Dennis Ritchie,&nbsp;father of&nbsp;Unix&nbsp;and an esteemed computer scientist&nbsp;might have implied the same approach for Unix directory structure. Why? Before getting into the hierarchy of&nbsp;Unix File Tree&nbsp;lets discuss why we need it. The need for &hellip; <a href=\"https:\/\/opstree.com\/blog\/2019\/07\/16\/unix-file-tree-part-1\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Unix File Tree Part-1&#8221;<\/span><\/a><\/p>\n","protected":false},"author":159458168,"featured_media":29900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[9203],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2025\/11\/DevSecOps-1.jpg","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-2k","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/144"}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/159458168"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=144"}],"version-history":[{"count":8,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/144\/revisions"}],"predecessor-version":[{"id":1229,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/144\/revisions\/1229"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/29900"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}