Filesystem Theory

What is a filesystem?

A filesystem allows the user to store the files on long term storage (disk drives for example). A filesystem allows the user to store, search, read, delete and keep files organized. The files are broken up into pieces and are stored then written to a disk. To gain a better understanding of file systems read section 5.10.1 from the Linux System Administrators Guide.

Spend some time and think about the operations that a filesystem can perform. Your list will probably include a majority of the following:

  • Create

  • Delete

  • Open

  • Close

  • Read

  • Write

  • Append

  • Seek

  • Get Attributes

  • Set Attributes

  • Rename

We should be familiar with most of these operations. The only operations that might be new are set and get attributes. You can actually use a command called chattr in Linux to set attributes of files. You can then retrieve those by using lsattr.

If the filesystem is able to do all these operations there also has to be a method to keep files organized. How do we keep track of how files are organized within a filesystem?

  1. The Pile

  2. Sequential

  3. Indexed Sequential File

  4. Indexed File

  5. Directed/hashed file

If the filesystem is storing all our data a means has to be provided to view files. This software is called the file management system. This software provides the ability to the user to view/use those files. This is a common piece of software that we use almost everyday and probably don't realize it.

Windows uses Explorer.

MacOS uses Finder.

Linux has many options, but one example is KDE Konquerer.

The file management software is what is providing us access to our files. This makes it a lot easier on the end user as we do not have to worry about how to access our files. Within our everyday use of computers we have become use to double clicking a file and having it open in the correct application. This provides the user with a nice experience, but it is not required.

File extensions.

Different types of files do exist. The file we are probably most use to use is a regular file, which contains user information. Another type of file we are use to using is a directory that is used for maintaining the filesystem structure. Finally, we have the character and block special files. These are ones that we are not as familiar with, but are just as important.

Directories are a great feature in a filesystem. Without the use of directories each users file would be in the same location! Talk about a mess! Directories also contain a lot of information. They contain their own set of attributes, the location and ownership information. We looked at the operations we can do on a file, so let us quickly look at the directory operations we can perform that are related to files:

    • Search

    • Create file

    • Delete file

    • List directory

    • Update directory

Directories also have other operations that do not relate to files.

    • Create

    • Delete

    • Opendir

    • Closedir

    • Readdir

    • Rename

    • Link

    • Unlink

Most of these operations should be familiar to you already, as we have been doing a majority of these over the years. The ones you are probably not familiar with are update, link and uplink directory.

Update: when a file has its attributes updated we might also need to update the directory to reflect those changes.

Link: This allows a file to appear in more than directory (we will talk about soft and hard links later in the semester)

Unlink: A directory entry is removed.

Helpful Terms in your Linux Journey:

Image showing Pathnames.

Pathname

A series of directory names, ending with the file itself.

(click image to enlarge)


Imaging showing current working directory, relative and absolute paths.



Absolute and Relative pathnames Current Working Directory

Absolute Pathname: no matter where this is used it will reference the same file.

Relative Pathname: Based on the current working directory.

Current Working Directory: The directory you are currently in and using.