My little introduction into the Linux filesystem

110

The Linux filesystem hierarchy is much like Apple’s OSX® filesystem hierarchy, as both have roots with Unix filesystem concepts and practices.

For system administrators that are used to Microsoft-based filesystems, the first difference you will notice is that there is a single root of the filesystem (expressed as ‘forward-slash’, or / ). The root is the top of the hierarchy, in which all internal and external devices, local and remote filesystems, directories and files are kept.

NOTE: The root of the filesystem should not be confused with the root user account, which is the system administrator’s account and has complete control over the system).

In Microsoft-land, hard disks, CD/DVD-ROM drives, USB and other external media, and even mapped network shares are commonly expressed in drive letters (A: B: C: etc). In Linux, OSX and Unix, all of these medias are mounted from within the root (again, / ) of the filesystem. For example, if you insert a CD-ROM disc into a Linux system’s CD-ROM drive, it will most likely be mounted under a directory such as /media/cdrom. Commonly in GUIs like Gnome, a CD-ROM icon will also appear on the user’s desktop for easy access – but don’t be confused, as this is basically just a pointer to the /media/cdrom directory. All of the files contained in the CD-ROM will appear under this directory.

This is the case for most all media in Linux. This approach to managing your files and filesystems will hopefully prove to become much more flexible and stable than others that have obvious limitations and fallacies (such as shifting drive letters).

NOTE: Keep in mind that the forward-slash separator ( / ) is opposite the Microsoft counterpart, which is normally a backslash ( ).

Some of the most common data locations that you’ll want to know about are:

The /home directory:
All user data (besides the root user) are normal kept in the /home directory. If you have user joe, his default home directory (unless you specified otherwise) will be /home/joe. User joe will have full permissions to create files and directories under /home/joe but not necessarily /home/jane. This is typically synonymous to the “Documents and Settings” concept in Windows 2000+. The root user is normally the only exception – /root is this user’s home directory.

The /media (and /mnt) directories:
The /media directory is where you will find device filesystems such as CD/DVD-ROMs and USB drives after you insert them (for example, under /media/cdrom). Devices that appear under /media are normally ‘auto-mounted’ by the system. /mnt is normally used as a temporary ‘mount point’ (such as manually mounting a digital camera under /mnt that isn’t automatically mounted by the system).

The /var directory:
Data kept in /var is normally is normally “variable” data such as system logs, printer/e-mail spool files and other transient and temporary files. /var/log is a commonly visited directory as it is where all system logs are kept – when you are troubleshooting a problem, this is a useful place to start. Another example is /var/spool/cups, where all printer spool files go when a user prints a document to a printer through the CUPS printing subsystem.

/bin, /sbin, /usr, /lib and /opt
All of these directories contain executable programs and their counterparts. It is not normally needed to peruse through these directories unless you are looking for something specific.

/dev, /proc, /tmp and /lost+found:
These are special directories. /dev contains device files that reference hardware such as modems, hard disks and mice. /proc contains an actual hierarchy of the system’s memory. /tmp is the default directory that all programs’ temporary files are kept. /lost+found is a directory that contains files that are
recovered by the system when a crash occurs (such as files that were in use if the system crashed unexpectedly).

For a much more technical and encompassing description of the Linux filesystem hierarchy, please visit the following page: http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/