Folders and directories provide an organized, hierarchical structure for managing files on a storage system, enabling easier navigation, duplicate filenames across locations, and granular access control. At the storage level, directories exist only as records in the file allocation table, while folders are their graphical representation in a GUI.
Folders & Directories
One of the things that really helps us manage files is folders and directories.
Really, files and folders are not much of a thing when it comes to your storage. If we look at our storage, it's made up of clusters, and we store data inside of these clusters. But it's not organized — it's just thrown into these containers, these clusters, and then we make reference to them so that we can pull that data, that file, out later on and access that file. At this point in time we don't really see any kind of directories or folders inside of our storage. It just doesn't exist.
I'm on my demo machine, and I'm going to use one of the Sysinternals tools to take a look at disk usage. This program is called d64, because "du" stands for disk usage, and it is command prompt. So what I'm going to do is copy this link right here, get into my command prompt, and change directory so we're inside of that Sysinternals folder. Then I'm going to use d64. We'll hit enter, and we see that we have to specify a directory at least, so I'm going to specify the directory — I'm just going to say the C drive. We're going to do that right there and hit enter.
It took a couple of minutes, but it finished up, and the thing that I want to show you is it says files, and there are 115,000 files on here. Imagine now if you're trying to search for a specific file out of 115,000 files — that could be crazy to search for. This folder right here has 160 items, and even scrolling through it is quite tedious. It takes a while to find certain programs in here, so 115,000 would be crazy.
Files, folders and directories give us a few different things, but the main thing is that it helps organize things for us. Without folders and directories it would be really difficult to find certain files. So one thing that this does for us is it gives us the ability to navigate and find certain data based off of some sort of hierarchy, where we click on a folder and get into another folder, and then we click on that to see different files or other folders that are involved in that. So we can find our files more easily and organize them.
There are other things that this does for us. For instance, it allows us to have the same file name, which might not seem like a big deal at first, but when you're working with large amounts of files with multiple users, having the same file name could be critical. We know we can't put the same file name in the same folder, because then how do we know which one's which — but what we can do is have a duplicate of a folder, so two folders that have the same data inside of them, and make a copy of it, and then they have the same names inside of there. That's one thing that these directory systems allow us to do.
It also allows us to control access. I may have a folder that I want to give access to a certain user or a certain group, so that they have access to it but they don't have access to the rest of the directories. It makes it a lot easier to assign permissions to a specific folder, and then you know that that whole folder is being shared out to those people.
So the question is, how do we come up with a directory system, because it doesn't really exist in this storage — we just throw data inside this storage. Somehow we need to store directory information, or what directory these files are in.
One thing we could do is just add the information to our allocation table. So here we have file.txt, and we see that it's in the temp directory right here, and here we've got file two, and we can see that that's in the example directory.
Another way we could do this is that within the allocation table, maybe the allocation table is broken down by different directories. In this case right here we've got a couple of files in the temp directory, and we've got a few files in the example directory. If we were to move one of them, then we would just remove it from one of the sections and put it into another section here. So we have the data points, or where it can be found, the clusters that it's in, and it would copy those over. Notice that the actual clusters never changed. The file didn't change location; we just changed it within our allocation table.
I bring up two different methods because I want to impress upon you that different file systems will have different methods on how they track that. But the point to all this is that it records this data in the allocation table, where the clusters don't actually change at all. If you were to move directory, it would just change the information here of wherever you're moving it to. It's just a simple little change in this table.
I'm back on my demo machine, and what we can see here now is the different directories that we're inside of. This is the command prompt right here, and what it's showing me is where I'm located at, directory-wise. I'm on the C drive, and then within the C drive I'm in the users directory — this backslash right here says I'm in a directory in the users — and then backslash, so another directory, demo user, and then backslash, so then we're in the desktop directory, and then backslash, in the Sysinternals Suite directory. So I'm in those directories.
Now, how do I navigate around here? Let's say I want to go all the way back to the main C drive here. I'm going to just go cd, which stands for change directory, and then I'll do a backslash, and that brings me way back here. Or let's say I want to get into the demo user. I'm going to do cd, and I'm going to do \users and then \demo user, and hit enter, and now I'm in the demo user.
I can go directory by directory, so I can just do cd desktop and hit enter, and now I'm inside of that directory. If I want to go back a level, I can do cd ..\ and hit enter, and now I'm going back a level. So I can navigate through these different areas here.
Perhaps I want to get to the — let's do cd demo — and I can also hit the space or the tab, and it will autocomplete, so that makes it easier to get into some of this. I'm going to do desktop and we'll autocomplete that. Then maybe I want to create a directory here, so I'm going to make directory, and we'll make a directory. Let's just call it test, and hit enter, and see what happens here. Now I can see over here I've got a folder that appears. So I've just created that directory, and then I can get into that. So cd test, I'm going to hit enter, and now I'm inside of that. As you can see, I can navigate around using these different commands.
I jumped onto an Ubuntu server here, and what I'm going to do is open up a terminal so we can see some similarities. Here I have what I'm logged in as, so the prompt looks a little different, but I'm going to do pwd, present working directory, and I can see I'm in the home administrator. I can do a change directory, or let's do a DI. Inside of here I see my desktop, so I'm going to get into the desktop right here. I'm going to do cd — and Linux tends to be case sensitive, so I need to make sure I do the case sensitive, usually, in Linux.
So I'm in the desktop. I'm going to close that for now, and I'm going to do a MK for make directory, and we'll do test, make directory test, and you can see that it popped up here in the bottom right.
One of the differences that you see is that there's forward slashes. For some reason forward slash was the standard, and for some reason Microsoft decided to not do the standard and did the backslash instead. But other than that, there's a lot of similarities in how we navigate through these different directories.
We took a look at what directories are: directories are a way that we can organize our files. So then the question is, what is a folder? Essentially they're the same thing. When we're talking about a graphical user interface, there is some sort of graphic that's representing something that's happening on the back end. We have directories on the back end, or what we use with the console, and what's being represented in a graphical user interface is folders. So essentially they're the same things — it's just the way it's being represented.
Through this command prompt we can see what directory we're inside. We're in the test directory, which is in the desktop directory, which is then the demo user directory, which is in the users directory. We can actually see that in folder form here on the desktop, and I can open it up and take a look inside of this. So here's the folder form right here, the folder representation through the graphical user interface, and here is the directory as we see it through the command prompt. That's the association between the two.
Because of the way our file structure works in our allocation table, and the way we specify directories, we can't reuse certain characters. For instance, the backslash can't be used within a file name, because then it gets confused — it doesn't know if that's supposed to be another directory or just the file name. So within the file name we can't have a backslash.
I'm on my demo laptop here with this file, and if I try to add something like the backslash here, then it's going to tell me that it can't add that backslash as a name, and then it gives me a few other characters that I can't add into that name. So there are some limitations on what I can name this file.
Within the NTFS file system there's also a size restriction, and that is that this path right here can only be so long. All of the characters of this path, including all of the directories and the file name, can only be so long. What I'm going to do for this one is create a new folder, so I'm going to go new, folder, and we're going to create a folder that has a big name to it, so I'm just going to keep typing this out. So I've created this folder with this extremely long name. What I'm going to do is create another folder with another extremely long name, and then we're going to drag one inside the other. Let's drag this into this other folder here, and we notice that now we get this "destination path too long". So the two combined, these two long names combined, are not acceptable to Windows. I've actually had issues with this in the past when these folders are automatically created in some systems and the file path gets too long.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →