The Linux directory structure is confusing at first but there is organization amid the confusion. It is actually loosely structured and the directories/subdirectories follow a basic logic. Linux is open source and there have been and always will be liberties taken in the organization of the directory structure. Here's my take on the basic directory structure and the contents:
/ - Root Directory
The root directory is the top layer of the filing system. All other directories are connected to it.
The /boot directory contains the files required to boot the system. The kernel(s) resides in this directory and typically there is a subdirectory for the boot loader: /boot/grub. The grub boot loader allows you to select between multiple kernels at boot time if needed. It's pretty nice as you can test out different kernels while still being able to boot to the original kernel.
The /etc directory holds the configuration files for most if not all of the startup and system processes, applications and daemons running on the computer. There are many subdirectories dedicated to a specific applications like apache or the boot-up processes like the hard-drive filesystem or init.d. The vast majority of the configuration files are text files that you can edit manually using a test editor or through a GUI. One very nice thing is that if your graphical user interface (X windows) doesn't work for whatever reason, you can still manually edit the files to fix what's broken.
The /bin directory holds binaries (applications) specific to the operating system that the user would access. Examples of these are the grep, netstat, demsg, dir, ls, more, etc.. These are considered programs that examine the system but can't hurt it.
The /sbin directory holds binaries (applications) specific to the operating system that the root user (administrator) would access. Examples of these are the mkswap, format, ifconfig, etc.. These are considered programs that can modify the system and can damage the system if used incorrectly.
The /lib directory holds the libraries and subdirectory libraries related to the operating system uses. Typically libraries filenames start with the letters lib and version numbers such as libsysfs.so.2. The applications will call-up these libraries when needed. For example: "the libsysfs.so library's purpose is to provide a consistant and stable interface for querying system device information exposed through sysfs". There subdirectories for various system level functions like /lib/linux-sound-base or /lib/modules
The /usr directory contains applications and application subdirectories that the usr would use. These are where the programs such as the Firefox web browser, LibreOffice or games are located. Typically, the subdirectory structure mimics the / (root) directory with a few differences:
The /dev directory contains the devices found on the computer. The devices are the the keyboard, hard-drive, ram, cpu, IRQs, etc.. You must be the root user to access these files as you can easily damage the operating system and computer if you don't know what you are doing.
The /var directory is an interesting directory that holds files that the system writes to as it operates. An example of what might be in the /var directory is the /var/log directory. Applications, programming languages and the operating system write their log files in /var/log. Also there will be subdirectories for print spoolers, caches and lock files. Strangely, it has become standard for the apache webserver to locate its webpages om the /var/www subdirectory.
The /lost+found directory to put it simply will contain the results of an attempted recovery from a system crash. If a computer running Linux is not shutdown properly or crashed, on the next boot-up, the fsck program will go through the system and try to recover any corrupt files that it finds. The result of this recovery operation will be placed in the /lost+found directory. There may be some important lost data recovered sitting there.
The /mnt directory typically contains the removable disks and drives such as USB drives, CD ROMS, DVD drives, floppy disks, etc.. Each physical drive is mounted into a subdirectory of the /mnt directory such as /floppy or /cdrom. When a device is not needed, the device is unmounted from the subdirectory. Typically, you must unmount a device before it will eject. This makes sure that the filing system has completed writing to the device and it is safe to remove the media.
The /tmp directory is used to hold temporary files that the operating system, process or an application uses while it is running. Once the process or application stops, the temporary files are deleted.
The /proc directory contains the dynamic processes that are running on the computer. Linx is pretty neat as all processes are treated as subdirectories containing text files. You can quickly find out what IRQs are used and to which cpu the IRQ is assigned to by using the following command: "cat /proc/interrupts". The "cat" program just lists the contents of a text file.
The /opt directory is supposed to hold all applications that are not part of the base Linux installation. In fact, few applications follow this rule. Most end up somewhere in the /usr directory. Examples of applications that you will find here are Firefox, java and Adobe. I have only 5 apps that follow this rule on my system. Sometimes getting open source programmers and developers to follow rules like this one is as successful as herding cats.
One of the most confusing directories is the /root directory. What the heck is with that? There already is a "/" root directory. The /root directory is the home directory of the Linux system administrator named root. The root user has a separate directory from all other users. This is because the root user must be able to log onto the computer or server. Under Linux, directories can be linked through the network to other computers such as the /home directory. If the link broke, the root user would still be able to log on the computer.
The /home directory contains all of the user's home directories. The user's home directories are subdirectories under the /home directory and are named after their user account. The user blanchae would have a home directory located at /home/blanchae. Programs like ftp have home directories also. The ftp home directory resides at /home/ftp. This is the subdirectory where external ftp users share their files.
If this page has helped you, please consider donating $1.00 to support the cost of hosting this site, thanks.