thursday tip day explaining the unix filesystem
For all linux/Unix n00bs out there, here’s a really good explanation of the layout of the Unix filesytem.
What’s in a file name? The files on a UNIX machine are organized in a hierarchy. The very top of the hierarchy is / —commonly referred to as “slash” or “the root directory.” If you change your working directory to / and run ls, you’ll see several subdirectories with cryptic names like etc, bin, var, home, and tmp. Although UNIX now supports long file names, most of the monikers of these top-level directories hark back some 30 years to the origin of UNIX. Similarly, by the same long-standing conventions, each directory contained in / serves a special purpose:
- /bin is but one of many directories that contain applications and utilities. However, /bin typically contains utilities that are essential to system operation. Hence, the shells, file-manipulation commands such as cp and chmod, compression and decompression, and diagnostics reside in /bin.
- /sbin also contains utilities crucial to system operation and maintenance. However, the programs found in /sbin can be executed only by superusers—hence, “superuser-bin” or /sbin. /dev incorporates all the hardware installed on your system, including terminals and USB devices (and other peripherals that are physically connected to the computer), pseudo-terminals (used to interact with X terminal windows), and hard disk drives, among others.
- /etc (often pronounced “etsee”) is dedicated to system configuration. The /etc directory contains configuration files for the system daemons, startup scripts, system parameters, and more.
- /home contains a user’s home directories. For instance, if your login name is joe, the directory /home/joe acts as your personal file repository.
- /lib is the coffer for essential system libraries. In modern UNIX, system libraries are typically shared, meaning that the libraries are not linked and included in each binary (which would waste space, at the least), but are loaded on demand when needed and shared by many applications at once. Hence, core applications and utilities installed with UNIX require the libraries in /lib to run, and you need at least a small handful of the libraries to create new executables from source code. All files here are vital, and the corruption or removal (whether intentional or accidental) of even one file can render a system useless.
- /mnt, short for “mount,” is the standard location to mount hard disk drive partitions and other devices. If you want to see which devices are currently mounted and accessible, simply run the mount command.
- /tmp, or “temporary,” is the system-wide scratch pad. Your Web server might stash session data files here, and other utilities use the space in /tmp for caching intermediate results. Files in /tmp are considered disposable. Indeed, your systems administrator probably deletes all files older than a certain expiry every evening.
- /usr is the umbrella for a great number of files. End-user applications—from editors, games, and interfaces, to system features—are here, as is the library of man pages along with much more. Chances are that if the file is useful but not mandatory for system operation, you’ll find it in /usr.
- /var —short for “variable”—is the repository for files that typically grow in size over time. Mailboxes, log files, printer queues, and databases can be found in /var. It’s commonplace also for Web sites to be kept in /var because a Web site tends to amass data preternaturally over time.
Read other posts