User-Level Intro to Linux

Module #05 - Linux File System

This module will be devoted to Linux file systems. More specifically, we will be dealing with the overall organization of the file system then how to manipulate folders and paths from the command line.

Very early in the semester, you were introduced to a GUI-based tool allowing you to do elementary navigation in the file system. This week, we’ll be re-learning these fundamentals from the CLI perspective and adding a few principles no end-user should be working without; e.g. Globbing, absolute / relative paths...

Topics Studied in this Module

T1 - Linux Hierarchy Standard
We will get started by a high-level overview of the file and folders structure in Linux systems. This will allow you to easily find your bearings on any Linux system.
T2 - Searching the Filesystem
When you are not able to find what you are looking for by using the above high-level "map", you need tools to allow you to search for specific files in a Linux filesystem.
T3 - Filesystem Structure
We wrap-up this module by examining the actual structure of a basic Linux filesystem. In doing so, we introduce the concept of inode and use it to illustrate how symbolic and hard links work in Linux.

Learning Activities

This module features the following learning activities; DF, PA, GQ

Linux+ Exams Objectives

This module deals with material related to the following objectives from the CompTIA Linux+ and LPI certifications exams.

  • Exam LX0-101 - Objective - 104.6 Create & change hard & symbolic links
  • Exam LX0-101 - Objective - 104.7 Find system files & place files in the correct location

This module is going to introduce you to concepts relating to the way Linux organizes files and folders.

T1 - Linux Hierarchy Standard

The Filesystem Hierarchy Standard is a way to standardize how UNIX systems organize their system-wide filesystem. It helps software package maintainers know where they ought to drop different kinds of files (e.g. configuration files, binaries, libraries...) when the package is installed. The following wikipedia page is a good starting point for reading about the FHS.

  • Reading Assignments: Wikipedia
  • URL Link: Filesystem Hierarchy Standard
  • Make sure you bookmark this resource to be able to refer to it quickly during exams.

In order to supplement the above, take also a look at the following video that will provide you with a hands-on exploration of the Ubuntu root folder.

  • The Linux Filesystem Layout
  • Video Link: YouTube
  • This video, from TutorialLinux provides an overview of the layout of the Ubuntu Linux File System. It reviews the main folders located directly below the Linux root ('/').

The above information should help you "feel at home" in your Linux system by allowing you to know where to look for specific types of files. However, sometimes, you will need to search through the filesystem to find a particular file. The next topic will explore available options to do so.

T2 - Searching the File System

Linux offers various tools to help you search through the filesystem. The following section of the Ubuntu official documentation will provide you with an introduction to a few of them.

  • Reading Assignments
  • URL Link: Ubuntu Documentation
  • This introduction provides the names and links to a few GUI-based file explorers that can be installed to help you look through your filesystem. However, for this course, the relevant part is the description of the following command line tools; apt-file, dkpg -L, dpkg -S, and locate.

Some of you might have already noticed that, in the above link description, I did not mention the introduction of the find tool. While the above Ubuntu documentation section introduces find, this tool needs a much more in-depth introduction as it is a tool that will allow you to search for just about anything in your filesystem. In addition, it is possible to specify specific actions to be taken on the files matching the profile you described. This makes the find tool a sort of Swiss army knife of filesystem tinkering that you should learn to master.

Let us supplement the above with a video tutorial for those of you who prefer to learn from more hands-on demonstrations.

  • Using find to Search for Files
  • Video Link: YouTube
  • This video from Joe James will also clarify some of the examples from the previous tutorial. More specifically, you will note that the find options used to specify time constraints are a bit confusing in the original tutorial. This video will provide better examples.

While the above is a good introduction to find, you still need to study the manpage in order to be able to refer back to it if you need to use a more advanced feature later on (hint, hint, again).

  • Reading Assignments: Man page
  • URL Link: find
  • Make sure you keep this page handy and study it to get a feel of the various options available. Use the module's forum if you have questions about any of these features.

T3 - File System Structure

Last but not least, we are going to conclude this module by taking a peek "under the hood" at how standard Linux file systems are organized. We will also use this information to clarify how Linux handles different types of links to files.

  • Inodes, Symbolic Links & Hard Links
  • Video Link: YouTube
  • This video from Jason Wertz introduces the fundamental concept of inode. It also explains how inodes are used to store the meta-data about files and folders in the Linux file systems. It then illustrate how understanding inodes helps understand the difference between soft (symbolic) and hard (physical) links.

The above video uses the ln command to both create symbolic (AKA soft) links, and physical (AKA hard) links. It is a good idea to take a look at the corresponding manpage.

  • Reading Assignments: Man page
  • URL Link: ln
  • Make sure you keep this page handy and study it to get a feel of the various options available. Use the module's forum if you have questions about any of these features.

The Discussion Forum for this module will require you to install some software on your Ubuntu virtual machine, test it thoroughly, and post a review for other students. See the previous DF assignment for details on expectations & guidelines.

Since this module offers you a choice between two topics, T1 and T2, make sure that your post's title specifies clearly the topic you chose.

Topic T1 - Review of GUI-based File Explorers

For this DF assignment, we will focus on GUI-based File Explorers or File Managers.

The following are suggested software packages to test, pick one that you will be able to use this week in order to establish whether it would be a suitable replacement for the tools you have been using so far to navigate your Ubuntu filesystem.

Please note that this means that the current default file explorer used in Ubuntu is not a suitable topic for this assignment.

Requirements for your Posts;

  • Whether the file manager you tested was developed for a specific distribution or desktop manager
  • What you had to do in order to get it to work on Ubuntu; e.g. install a different desktop manager or at least its supporting libraries
  • What are its distinguishing features compared to the CLI or the simple GUI-based file manager which is default in Ubuntu

Topic T2 - Review of UNIXvisual

The following tool has been developed to help students learn how Linux file permissions work. Download it, install it and post in the DF forum a review along the lines specified below.

The following resources will help you in this task;

  • Website where to download the app: URL
  • Quickstart manual: URL
  • Paper describing the system and its pedagogical intents URL (The PDF download will be free if you are on USF wireless or VPN)

In order to run this program, which comes as a .tar.gz file, you will have to do the following;

  • tar oxzvf UNIXvisual_Linux64.tar.gz
  • cd ./UNIXvisual/
  • ./UNIXvisual

Requirements for your Posts;

  • What features are available in this tool that are relevant to a student working on this module
  • For each feature, how they might support learning
  • For each feature, what do you feel is lacking to make it truly helpful to students
  • What feature(s) do you feel are missing

The following exercises will allow you to practice with the various tools we discussed in this module. You will generally have to consult the manpages for the tools being used in order to identify the options and syntax that allow you to perform the required task. This will allow you to supplement what we covered so far in the study material while also developing the skill to read and understand technical documentation in order to apply Linux command line tools to new tasks.

In order for you to get the most out of each question in this assignment, it is a good idea to provide the information below whenever applicable to a question.

  • Explain briefly in your notes how you came up with your solution
  • Provide references to all sources of information you used; e.g. manpage / webpage
  • Do not provide “hypothetical” solutions with syntax errors, instead, test things on your Linux system then provide the shell line / solution you really used
  • Explain briefly in your own words how you validated your solution
  • Provide evidence your solution works; i.e. screenshots

Exercise #1 - The Filesystem Hierarchy Standard

One important concept to understand when working in Linux is the Filesystem Hierarchy Standard. The FHS specifies a standard schema for the filesystem which all Linux distributions follow in order to help maintain compatibility. Various directories in Linux are defined to serve a specific purpose as determined by the FHS.

Do some research on the FHS and explain the purpose of the following directories:

  • /
  • /bin
  • /boot
  • /etc
  • /home
  • /lib
  • /proc
  • /root
  • /sbin
  • /tmp
  • /sys
  • /var

Submit a one sentence explanation of the function of each of these directories.

Exercise #2 - I am looking for some executable

Use the find tool to list all the executable files which name starts with trace and that are located inside the /usr/ folder and its subfolders. If some of the folders are not accessible to your user, use sudo to empower your command to look through them.

Submit a screenshot showing the command you ran, its output, and your full name in the terminal.

Exercise #3 - Just the basename please

The previous exercise allowed you to get a list of file names that matched specific criteria. Now, we would like to have find apply to all of them a command that remove the leading path information and just keeps the basename of each file.

Submit a screenshot showing the command you ran, its output, and your full name in the terminal.

Exercise #4 - Dashing through the logs

We now want to apply the same kind of skills to get an idea of log files that have been recently modified within 5 minutes. Try to solve this problem by following these steps;

  • Figure out where in the Linux standard hierarchy, most log files would be stored
  • Use find to explore that part of your file system, looking for files that are of type regular files which names end with the suffix ".log"
  • Further restrict the above list by looking only for files which permissions allow everyone, the owner and the group to read them
  • Verify that the previous syntax works as expected by having find perform a ls -l on every file found so as to display its permissions.

Submit a screenshot showing the command you used to find the log files which match these criteria You only need to show the final command which you composed to achieve these results, it is not necessary to explain the intermediary steps. However, as usual, make sure you type your full name in the terminal so that it shows in your screenshots.

Exercise #5 - Find some more

This exercise is OPTIONAL. You do not have to submit anything for it.

So far, we have used find with very simple tests. However, its tests are not restricted to single-term Boolean expressions. Instead, we may use logical and, as well as logical or operators. Research the syntax available to introduce such multi-terms tests.

Provide an example of how you would apply this knowledge to use the find tool to list all the files on your Linux system which have a file size between 4 KB and 12KB. Please make sure to reduce the amount of “garbage output” in all your searches.

Provide an example of how you would use the find tool to list all the files on your Linux box which have a “w” or “x” in their permissions for “others” regardless of their permissions for “owner” and “group”.

We would like to validate by having the same shell line display for each of the files we found its permissions details. The find tool allows executing just about any shell command to the files which are found. Research the syntax to do so and provide the shell line you would be using below.

This tab provides you with optional resources meant for those who want to learn a bit more about the topics covered in this module.

Extra resources on find

  • Learning find with 50 examples
  • Video Link: YouTube
  • This video was shared in our summer 2018 forums by Ankitkumar Patel. It will provide you with a great set of examples of using the find tool.

Harley Hahn's Guide to UNIX and Linux

If you are interested in learning more about the Linux File System, I recommend you look for Harley Hahn's Guide to UNIX and Linux. It is unfortunately out of print but is a great (and entertaining) read about the topic.

The following sections of the above are particularly relevant to this module;

  • Section 23 - The Unix Filesystem
  • Section 24 - Working with Directories
  • Section 25 - Working With Files