Linux Filesystem
November 12, 2016 5 minutes • 1039 words
These directories are required in /.
Directory | Purpose |
---|---|
/bin | Essential command binaries |
/boot | Static files of the boot loader |
/dev | Device files |
/etc | Host-specific system configuration |
/lib | Essential shared libraries and kernel modules |
/media | Mount point for removeable media |
/mnt | Mount point for mounting a filesystem temporarily |
/opt | Add-on application software packages |
/sbin | Essential system binaries |
/srv | Data for services provided by this system |
/tmp | Temporary files |
/usr | Secondary hierarchy |
/var | Variable data |
Additional directories are in / if the corresponding subsystem is installed:
Directory | Purpose |
---|---|
/ | the root directory |
/home | User home directories (optional) |
/lib |
Alternate format essential shared libraries (optional) |
/root | Home directory for the root user (optional) |
Linux file systems start with /, the root directory.
All other directories are ‘children’ of this directory. The root is mounted first during boot. The system will not boot if it doesn’t find it.
/lib
This has kernel modules and those shared library images (the C programming code library) needed to boot the system and run the commands in the root filesystem, ie. by binaries in /bin and /sbin.
Libraries are readily identifiable through their filename extension of *.so.
Windows equivalent to a shared library would be a DLL (dynamically linked library) file. They are essential for basic system functionality. Kernel modules (drivers) are in the subdirectory /lib/modules/‘kernel-version’. To ensure proper module compilation you should ensure that /lib/modules/‘kernel-version’/kernel/build points to /usr/src/‘kernel-version’ or ensure that the Makefile knows where the kernel source itself are located.
Subdirectory | Purpose |
---|---|
/lib/‘machine-architecture’ | Contains platform/architecture dependent libraries. |
/lib/iptables | iptables shared library files. |
/lib/kbd | Contains various keymaps. |
/lib/modules/‘kernel-version’ | The home of all the kernel modules. The organisation of files here is reasonably clear so no requires no elaboration. |
/lib/modules/‘kernel-version’/isapnpmap.dep | has details on ISA based cards, the modules that they require and various other attributes. |
/lib/modules/‘kernel-version’/modules.dep | lists all modules dependencies. This file can be updated using the depmod command. |
/lib/modules/‘kernel-version’/pcimap | is the PCI equivalent of the /lib/modules/‘kernel-version’/isapnpmap.dep file. |
/lib/modules/‘kernel-version’/usbmap | is the USB equivalent of the /lib/modules/‘kernel-version’/isapnpmap.dep file. |
/lib/oss | All OSS (Open Sound System) files are installed here by default. |
/lib/security | PAM library files. |
Shared libraries that are only necessary for binaries in /usr (such as any X Window binaries) must not be in /lib. Only the shared libraries required to run binaries in /bin and /sbin may be here.
In particular, the library libm.so.* may also be placed in /usr/lib if it is not required by anything in /bin or /sbin.
At least one of each of the following filename patterns are required (they may be files, or symbolic links):
libc.so.* The dynamically-linked C library (optional) ld* The execution time linker/loader (optional)
/lost+found
This stores recovered files that may have been lost during sudden shutdowns.
When Linux shuts down unexpectedly, it does a lengthy filesystem check* using fsck. It will try to recover any corrupt files that it finds and places it in this directory.
*Ext3, a journalled filesystem, will finish the check faster than ext2
Each partition has its own lost+found directory. If you find files in there, try to move them back to their original location.
If you find something like a broken symbolic link to ‘file’, you have to reinstall the file/s from the corresponding RPM, since your file system got damaged so badly that the files were mutilated beyond recognition.
/home
Each user has its own home directory under ‘/home/$USER’ (~/).
Personl config files here have the convention: .name and are hidden. These can be ssen by unhiding in the file manager or ls -a
in the terminal.
If there is a conflict between personal and system wide configuration files, the settings in the personal file will prevail.
/tmp
Has temporary files. Many programs use this to create lock files and for temporary data.
Do not remove files from this directory unless you know exactly what you are doing!
Many of these files are important for currently running programs. Deleting them may result in a system crash.
This directory is usually cleared out at boot or at shutdown.
/root
This is the home directory of the System Administrator ‘root’.
In the past, ‘/’ was root’s home directory hence the name of the Administrator account.
To keep things tidier, ‘root’ got his own home directory.
‘/home’ was often located on a different partition or another system and be inaccessible to ‘root’ when only ‘/’ is mounted.
/srv
Has site-specific data which is served by this system.
This main purpose of specifying this is so that users may find the location of the
This has the data files for a particular service so that services which require a single tree for readonly data, writable data and scripts (such as cgi scripts) can be reasonably placed.
Data that is only of interest to a specific user should go in that users’ home directory.
/media
This has the mount points for removable media.
On systems where more than one device exists for mounting a certain type of media, mount directories can be created by appending a digit to the name of those available above starting with ‘0’, but the unqualified name must also exist.
A compliant implementation with two CDROM drives might have /media/cdrom0 and /media/cdrom1 with /media/cdrom a symlink to either of these.
/opt
This is reserved for all the software and add-on packages that are not part of the default installation.
For example, Netscape Communicator and WordPerfect packages are normally found here. All third party applications should be installed in this directory.
Any package to be installed here must locate its static files (ie. extra fonts, clipart, database files) must locate its static files in a separate /opt/‘package’ or /opt/‘provider’ directory tree. This is similar to how Windows installs new software to C:\Windows\Progam Files"Program Name")
Under no circumstances are other package files to exist outside the /opt, /var/opt, and /etc/opt hierarchies except for those package files that must reside in specific locations within the filesystem tree in order to function properly.
For example, device lock files in /var/lock and devices in /dev.
Distributions may install software in /opt, but must not modify or delete software installed by the local system administrator without the assent of the local system administrator.
Generally, all data required to support a package on a system must be present within /opt/‘package’.