Linux Directory Structure

In this post, I would like to touch on the Linux directory structure and the purpose and function behind each directory. As you probably already know, / (root) is the highest level directory and everything exists beneath it. The functions of some things like /home and /boot are pretty obvious, but what about /proc or /etc? No worries! I’ll show you!

/

This is the root directory itself. All files and directories exist under this directory. An important point to note is that the sub-directories under root may not actually be on the same partition or even disk, this is just the organizational structure.

/bin

This directory stores the most critical programs, or binaries (hence /bin) that the system needs to operate. Both the most common shells (dash, bash) reside here, along with a lot of the “base” commands you encounter (cp, df, grep, ln, ls, rm, etc.).

Note that the directory /usr/bin contains binaries as well. This directory is usually more user-oriented and contains applications (gimp, gthumb, inkscape, vlc, wine, etc.) along with other binaries (id, lshw, make, top, wget)

/boot

This is the place where the, duh!, the boot files are stored. A simple directory listing here will show you things like memtest86+ (a memory testing utility installed with many distributions), vmlinuz (the Linux kernel), and grub (or lilo, two of the most common and prevalent bootloaders)

/dev

This contains all the devices (note that devices are treated as files in Linux) that are accessible by the Linux filesystem. It is typically automatically populated at boot by Udev.

/etc

The configuration files for the Linux filesystem are stored here. For example, /etc/ssh/sshd_config and /etc/samba/smb.conf contain the configurations for SSH and  Samba respectively.

/home

This directory contains the personal files (Desktop, Documents, Music, Pictures, Videos, etc.) for each of the users, at /home/<username>.

/lib

Dynamically linked shared libraries reside in this directory. If you are coming from a Windows background, the items in here are very similar to DLLs you’d find at (C:\Windows\System32 or C:\Windows\SysWOW64)

/lib64

Same as /lib but this directory contains 64bit libraries.

/lost+found

The lost+found directory contains files that have been restored after a system crash or filesystems that were not dismounted cleanly.

/media

Removable filesystems such as cd-roms, floppys and flash drives are mounted here.

/mnt

“Permanently” mounted filesystems are mounted here. This typically includes partitions, internal drives and manually added contents from /etc/fstab.

/opt

This directory is for optional software packages and files.

/proc

This is a special virtual directory in which running processes (numbered) are located as well as entries that configure the running system (named).

/run

This is a temporary filesystem which stores volatile runtime data.

/sbin

This directory is similar to /bin, except that the majority of the binaries that reside here require root access (i.e. sudo) in order to be run (blkid, fdisk, mkfs, mount, shutdown, etc.).

Note that the directory /usr/sbin contains binaries as well, but like /sbin, they typically require root access (chroot, groupadd, update-grub, useradd, etc.).

/srv

In here, site-specific data for the system in stored. Services such as http. ftp, rsync, www and cvs are stored here.

/sys

This directory is a virtual filesystem which stores and allows modifications to devices.

/tmp

Temporary files create by programs are stored in this directory.

/usr

This directory contains items that pertain to the system users such configuration files and graphics (/usr/share), source code (/usr/src), C/C++ headers (/usr/include) and shared libraries (/usr/lib)

/var

This directory contains files that change as the system is running. A few notable items are the system log files (/var/log), incoming and outgoing mail (/var/mail), and printer spools (/var/spool).

Tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Protected by WP Anti Spam