In cyberspace, almost no one can hear you blog.

Directory Directions...a Guide to the Linux File System

Date/Time Permalink: 03/16/06 03:54:27 am
Category: HOWTOs and Guides

Every now and again, it pops up on a Linux forum: "What does ⁄mnt stand for?" or "Where would I find log files?" Herein, a tour of the Linux file system, from the roots outward:

⁄bin: where "binary" programs live. Most of your system's executable files run from here.

⁄boot: the special programs that boot the system when you turn the machine on. If your system's running fine and you're not adding or removing a new system, you're better off not diddling around in here.

⁄dev: aaaaaalll the "device" listings for hardware of every conceivable flavor, along with some "imaginary" devices, like ⁄dev⁄null and ⁄dev⁄zero. When you get a random number it usually comes from ⁄dev⁄random.

⁄etc: configuration files, aka "etcetera". It's purpose in life is to host various configuration files from around your system. For instance, to add a new hard drive to your system and have Linux auto-mount it on boot, you'd have to edit ⁄etc⁄fstab. If you're stuck in the console and can't start your desktop because the X window system is reporting errors in your configuration, a trip to ⁄etc⁄X11⁄xorg.conf is in your future.

⁄home: the user's home directories live here. Within your ⁄home⁄you⁄ directory, you have complete freedom. BUT - your home directory also serves as an "⁄etc" (see above) that's just for *you* - so when you log onto the system, Firefox shows your bookmarks and not your roommate's, thanks to the "dot-files" (they start with a ".") in your home directory. So within my home folder, I create a folder which I consider *mine*, where nothing else will write to it, so I know exactly what's what (and so I don't accidentally blow away my fluxbox settings when I remove another folder!)

⁄lib: the "library" files that programs need to run, if they are compiled to link against these libraries. Another great place to stay away from, unless you're a programmer or you're fixing something.

⁄lost+found: look here after a system crash⁄kernel panic or other extreme scenario to find "orphaned" files. Sometimes messy installs of new distros leave abandoned files here, as well. Messy, messy, messy!

⁄misc: kinda reminds you of ⁄etc, doesn't it? Some systems have this and some don't. It's usually used as a mount-point for "miscellaneous" devices by auto-mounters.

⁄mnt: "mount", the directory that acts as a gateway to every other disk or file system or removable media. Floppies are accessed from ⁄mnt⁄floppy, your second hard drive might be ⁄mnt⁄hd here, and so on.

⁄opt: "optional", where programs that are installed after the initial system install sometimes end up. Also where the KDE desktop environment sets up housekeeping, for completely unknown reasons.

⁄proc: running "processes". The "everything is a file" paradigm carried to the Linux degree! This folder hosts files which keep tabs on boring stuff like what daemons are running and the process ID of Emacs while you have Emacs open.

⁄root: root's home! root is so special, it gets it's own major directory!

⁄sbin: the "system-administrator's bin file", which hosts programs that would be in ⁄bin if they didn't have "root-only" access permissions.

⁄tmp: "temporary" files, of use by programs which need to throw together a data file on-the-fly in preparation for executing some other task. This folder gets flushed on reboot. Think of it as a "scratch pad" for the programs on your system.

⁄usr: Bet you thought it meant "user", didn't you? Ha, it *actually* stands for "Unix System Resources"! Practically a whole other system in here, ⁄usr⁄bin is still more binaries, ⁄usr⁄doc and ⁄usr⁄share⁄doc are documentation folders, ⁄usr⁄share⁄games⁄fortune is where the funny quotes come from when you log on (if that feature is enabled). The idea is that this should be where files⁄programs accessible by all users should be, and thus your desktop backgrounds come from ⁄usr⁄share⁄wallpapers, or such. The other case is newly installed programs sometimes end up in ⁄usr⁄local⁄bin. Even though I've known this for a while, I still call it the "user"'s directory.

⁄var: "variable". System logs in here, recording such things as the last foo commands typed at the prompt, start-up boot messages, and such.

The whole file system evolved by consensus over eons, and is usually consistent from one distro to another. The burden is also on developers writing install applications to use this file system, and not make up weird other schemes on their own whim. However, distro-drift has taken it's toll, and not every folder mentioned here is on every distro, and new ones probably lurk on systems as yet unexplored by me (possibly by anyone else?). The rule of thumb to remember: If ⁄bin=binary programs, then any other folder path ending in ⁄bin will also have binaries. Ditto for ⁄doc and ⁄etc.

Happy geeking!

UPDATE 8/2/06: Found this file system chart. Now, why didn't I think of that?

Follow me on Twitter for an update every time this blog gets a post.
Stumble it Reddit this share on Facebook

suddenly the moon