Skip to content
benschenker edited this page Nov 30, 2014 · 2 revisions

The Unix File System

Understanding the Unix File System is an important task for every developer as it organizes all of our files and that is where our awesome code lives!

Bottom Line: The file system provides a tree-like structure for our files.

A file is simply a bunch of encoded numbers. They can be encoded in a human readable format (like our code) or in a machine readable format (like an executable). A file will live inside a directory, which is called it's parent. Directories can also have parent directories and this starts to form the tree structure that we mentioned earlier.

(Insert graphic showing an example tree directory structure?)

In Unix, the directory that is the ancestor of all of the system's other files and directories is called the root. This is written as /. Since all files and directories are descendants of root, we can always refer to a file with a reference to root.

(Insert relevant graphic for example below)

Example 1

To refer to a file TestFile.txt who lives in FancyDirectory directly under root we would use the following string:

/FancyDirectory/TestFile.txt

This string is what we call a path to the file. When we specify the path from root to the file this is known as the absolute path. The slashes are there to indicate moving from one directory to another directory or a file. There is one other type of path, but first we must take a detour.

Whenever we interact with the Unix file system we do so from the current working directory or the directory that we are looking at. If we want to refer to a file that is in our current working directory then it is a bit cumbersome to write out the absolute path. In that case we can use the relative path.

(Example using relative path vs absolute path)

One other nifty aspect of the Unix file system is that it has a fairly robust way of enforcing permissions. Permissions could deny access for the reading, writing, or execution of a file. You can read more about permissions at (Insert link!!).