What is the filesystem?

Antoine Vernet
4 min readMar 2, 2022
What is the filesystem?

This is the transcript of my video, what is the file system? that you can find on YouTube.

Welcome to this video about the filesystem. The filesystem is the way your computer stores and retrieves files on your computer. It tells the computer where the files are. And not only do your computer have a file system, but your phone and your tablet also have a file system. The difference is that phones and tablets tend to hide the file system from us. We don’t very often see where our files and directory are in a tree structure when we look at our phone or when we look at our tablet, but on the computer, we can have access to that tree directory much more easily.

Understanding the basics of the file system will make your life much easier when programming and when trying to work with data. It will allow you to tell the computer where the data file you want to load is and it will allow you to save the files you need in the places you want them saved into. So in summary, the file system is going to allow you to find files, to write files in specific places, and to more broadly organize your work and make your work more shareable.

So in most computers, in most operating systems such as Windows, Mac OS and Linux, files have a name. And on top of that, they have a file path. And I’m going to show you very briefly what I mean by a file path. So if you look at the the series of directories and files I have here, so I’ve got a directory that contains the sub directory and that subdirectory contains a file.

If we open the file, we can see the content of this file right now. If we want to tell the computer to open that file in a programmatic way, we need the path of the file. And you can see this thing where it says where the file is: this is the complete path to the file. It’s on my hard drive, users, my name, the desktop directory another directory called directory and then subdirectory.

The good thing on Mac OS and the same will happen on Windows is that if you copy this and you open the text file and you copy it into a text file, it will format it in the way that your computer will be able to read. And so if I want to tell the computer where the file is, I will need that path and then I’ll need to append at the end the name of the file.

And so it’s a text file, so it’s dot txt. And this will allow me to tell the computer programmatically where to find that file for example, in order for it to open the file, or if I wanted to create a new file to save some of my work. I would use a similar path. So the path I’m using now is the absolute path. It tells where exactly the file is on my computer. The downside of this is that if I give you my piece of program and you try it on your computer, that piece of program is going to break because the absolute path of the file on your computer is going to be different than it was on mine For example, you’re going to have a different username than my computer because my computer is called Antoine Vernet, which is my name. And your computer is likely to have your name there. So this is why absolute paths, while they allow us to find files and do all we want on our machines, lead to issues when we try to share code. And that’s where the notion of a relative path is really useful.

What are we thinking about when we’re using relative paths? We’re thinking about a project and our work is contained within a project. In this case, it would be that directory that has a subdirectory and a file in it. So the directory is a project and everything else is what’s in this project. What we can do is, I would give you all of my structure. I would give you that directory for you to run code. And then within that directory in my code, I would use relative paths and those relative paths would look something like the following. So relative path are always related to something. In this case, I said that would be directory, so my path would start a subdirectory. Every path would be given relative to the project level, which in this case is the directory. So if I wanted to tell you the address of the file dot txt, it would be subdirectory and then file dot txt because that’s where where it is relative to that directory.

So you see relative paths are very powerful in order to help us clean up our work, make our work more robust by making it more shareable and then you see that when you start sharing code, when you start sharing data and analysis, you just can share the directory that contains all of your project work, and then someone else can open it and work with it pretty seamlessly.

If all of the reference to paths are made relative to that project directory and we’ll see a number of ways in which we will use this. One good way to do to do this and one way to to do it pretty robustly is to use R Studio projects. And those R Studio projects are a way of creating that project level directory and then making sure that R understands it as a contained project where everything inside is going to be relative to that project.

I hope that was useful. And that gave you some background idea of how the file system works. Thank you very much.

--

--

Antoine Vernet

I write about cool social science, old and new. I am an associate professor at UCL. https://www.youtube.com/@antoinevernet