Core Concepts: The Linux Filesystem

One of the common things most Linux users come into contact in learning their system is the file system structure.  Whether it be modifying files, making symbolic links, configuring Xorg, SSH, and much more, it is highly useful to familiarize yourself with the common paths and sections of your root (denoted by the “/” symbol) directory.  I will also list non-root directory and their purposes as well.

Read on for more…

What in the WIDE WORLD OF SPORTS is that?  It may look quite daunting at first, but don’t be scarred!  It’s the friendly Linux filesystem!  And trust me it is much* more fluid and simpler than Windows (of course..).  What we will be exploring is the left most part of this graph, as well as where that leads to, denoted by some of the other branches to the right.  Let’s get started:

/ (root) :

This is where every single file on your Linux install resides, the epicenter, the core, the mecca of it’s well being.  I suppose you could equate it to C:\ drive on Windows, but it is much more than that.  You generally should not be placing any files right at this level.

/boot (boatloader files):

This is where your bootloader files live.  It is useful to make this on a separate partition on installation, but is not required.  The Kernal, vmlinux, and your grub files (the most common boot menu, other than LILO) are located here.

/dev (device files)

This path contains all your device files, such as attached CD/DVD/BluRay drives, virtual TTY lines and more.

/etc (configuration files)

This is one of the most common areas you delve into.  The home of Xorg, grub configuration files, shell scripts, and configurations of individual programs, it is a valuable area to get to know.

/home (user files)

This is where all your personal files from any created users reside.  It is highly* beneficial to create this on a separate drive/partition on install.  This will enable mobility across Linux distributions, but be careful of how you store files from each, as to not get confused with software installers and other files.

/lib (system library files)

This path contains library files (no, not outdated copies of movies from the 70’s and Dr. Seuss books) that support the binaries located under /bin and /sbin.  These files typically end in .so or contain *ld or lib*.

/Lost and found:

Pretty self explanatory, this path is where recovered files from important utilities such as fsck will place restored/reclaimed files.  Also located here can be orphaned files from a software/operating system bug that rendered the system in an inconsistent state.

/Misc:

I am not sure of this directory.  It is included in the diagram, but not common to most Distros.

/mnt (mount directory):

This is a temporary directory for attached storage you may connect to your computer.  Some also mount to /media/user_name , but this is the proper area.  Sysadmins usually mount devices under this path.

/Net :

I am not sure of this directory.  It is included in the diagram, but not common to most Distros.

/opt (optional add-on applications):

As the name states, this is an optional path for applications.  Vendors may place files in here as installed addons for their programs in this path or a sub-directory of it.

/proc (process information):

This path contains system process information.  It is not a typical system path as the others, a sort of “pseudo filesystem” that gives you information about running processes.  When you run the command ps -ef, to find the PID of a process, you are querying the /proc/{pid} directory.  This virtual filesystem contains simple text about system resources as well, such as system uptime.

/root (not to be confused with /):

Don’t confuse this with /, which is where ALL of these paths reside.  This is a separate path, which contains the “root user’s” home directory.  If you are a horrible person and run everything as the root user, you’ll see many files here (jk, I trust you!).

/sbin (system binaries):

Similar to /bin, /sbin  contains executables.  Be advised though, this particular location is generally reserved for Sysadmins for maintenance, and not for general binaries by a user.  You often will find binaries for things like fdisk, blkid, reboot, iptables, and more here.

/tmp (temporary files):

This is a path that contains temporary files created by users as well as Sysadmins, and is emptied after each reboot.  I suppose it could be compared to the “local” hidden directory of a user in Windows

/usr (user programs):

This is another very common path and one you should be familiar with.  This will contain binaries, libraries, documentation, and source-code for second-level programs.  The sub-directories are just as important as its root directory.  /usr/bin contains binary fiels for user programs such as more, less, awk, sed and so on.  /usr/sbin contains binary files for Sysadmins that typically are not found in /sbin such as cron, sshd, useradd, userdel, and so on.  /usr/lib contins libraries for /usr/bin and /usr/sbin.  /usr/local contains users programs that were installed from source (another subject and animal of itself I will cover later).  For instance, if you install MakeMKV from source, it typically winds up here as “/usr/local/MakeMKV.

/var (variable files):

Var is short for variable.  This path will contain objects that often get larger in size as you use certain aspects of your system.  Examples of this include system logs (/var/log), packages and database files (/var/lib), lock files (/var/lock), and more.

/media (not pictured, Removable Media Devices):

This path can also   removable devices such as USB drives, CD-ROM drives, and more are automatically mounted.  This is in contrast to the manual mounting directory of /mnt.   It is suggested you keep the two separate, although you can interchange their paths.

That’s it!  Any questions, leave them below.

-Professor

Advertisements

About professorkaos64

www.libregeek.org

Posted on 20130624, in Core Concepts and tagged , , , , , , , , , , , , , , . Bookmark the permalink. 4 Comments.

  1. /root is the root user’s home directory.

    sudo su
    cd
    pwd
    > /root

  2. Another great article. Keep them coming 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s