Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If I install an application in Linux for example Debian/Gnu Linux, the files of the applications are copied to many different directories in the file system.

Some scripts goes into /usr/share .. /usr/local some other files into /var .. /log .. etc/ and so on.

For me this is o.k because I learned something about the file system and most of the directories are there to hold files for a specific purpose. This fits very nice in the Unix philosophy "do one thing and do it well"

But my question is what are the advantages of such a directory structure? Or is it simply the heritage of the old unix days. (e.g in comparison with the one windows use, where all files for an application are in one specific "folder")

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

What seems to me the easiest-to-think-of advantage is that similar files live in the same directory tree. Configuration files live in /etc, log files and/or run-time trace files live in /var/log, executables live in /usr/bin, run-time information like PID files lives in /var/run. You want to know what's in the NTP configuration file? Change directory to /etc and do ls ntp*. You want to have some program watch executable files so that some traditional file system virus doesn't infect them? Everything in /usr/bin and /usr/local/bin needs watching.

The second advantage I can think of is that the Unix style of organization promotes a separation of data and executable. Executables live in a directory that's well away from where templates live (/usr/share, probably), and well away from where data lives. That separation might be a reason why Unix/Linux/*BSD have more resistance to file system viruses than Windows does, or the old Pre-OSX Mac had.

share|improve this answer
    
That are good points. Why is the separation of executable and data-, template-, config-files a reason for more protection against viruses? –  Jan Koester Jan 17 '13 at 19:33
2  
A lot (but not all) of the viruses and worms in the world propagate due to the ability to change data to executable: stack overflows and SQL injection and code injection all work this way. "Word" macro viruses propagated at least partly because "Word" macros are included in .doc files. Separation of data from executable by file is one level of protection, putting data in one directory, executable in a second, templates in a 3rd, config in a 4th puts even more barriers to confusing data and executable into place. –  Bruce Ediger Jan 17 '13 at 20:31
    
The data-and-executable separation argument is complete nonsense. File system organization is for a human's benefit; it's not like there's some physical separation between the bits that prevents them from giving cooties to each other or anything. UNIX's security is historically better because of a stronger, more-tightly-enforced permissions model in general. –  fluffy Jan 17 '13 at 20:54
    
@fluffy Separate filesystems offer slightly stronger separation, but that point is partially moot as it is not possible to separate /bin, /etc, from /. –  jw013 Jan 17 '13 at 21:47
    
@fluffy - agreed, no "physical" separation exists, or is possible. But it's a separation-by-name. Malware has to look in some other directory (rather than "." or dirname $0 or something) to find templates or other data. It's not absolute security, any more than closing a glass window is absolute security. Security is an economic good, with marginal value for each additional unit of work. Every little bit helps. –  Bruce Ediger Jan 17 '13 at 22:01
show 1 more comment

There aren't really any advantages to this layout, aside from it being easy to guess where shared and configuration files are for an application. UNIX has a long legacy of this sort of layout, and to break it would be pretty difficult. However, some UNIX distributions have changed their model - they only provide the old locations for legacy purposes, and other apps are bundled into its own little directory/package. Mac OS X is the most prominent example of this, and there are a few obscure Linux distributions which do the same thing (and Android does something similar, only takes it a bit further and installs and launches every application under its own user ID as well).

The main thing that a filesystem convention provides is just that - a convention, so that people know where to look for files (be it manually or in code). There is no real technical reason for it to be one way over another.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.