Skip to content

Directories, Roots, Folders & Home Directories and their differences on Linux and Windows

  • by

Introduction

In this article I’m going to drill into many technical nuances of what data structure names are on your computer. This will involve owners, permissions, folders, directories, any many quircks in between, also comparing the differences between Windows and Linux and Mac.

Folders

Most of us know what a folder is. The analogy is straight forward enough to know that we put files inside of folders. The files can be anything, from photographs to Word documents to more folders to random data files we have no idea what they’re for!

Everything on your computer sits inside some kind of folder. Even cloud repositories have folder systems.

Using folder systems allow the user to organize their data. Once again, the analogy is very clear here. Imagine a desk with files all over the place in little piles that overlap and mix with other piles and all it takes is one funny gust of wind to the desk and everything is scattered around the room. We don’t want this, so we organize our documents on our desk into file folders which then get sorted into a cabinet for future (easy) reference.

The trick here, of course, is to make effective folder systems. This is a conversation I’ll leave to another time. If you’re interested in this subject, it’s called ‘Data Structures’. There’s University courses on the topic and many a text books.

Directories or Folder Structure

C: folder directory

C: folder directory

The term directory refers to folder structure on a computer. In the image above, I have shown the C: drive directory on my Windows computer. When I say C:, you can read this as C drive. The : implies it’s a drive. What’s before the : is the letter assigned to the drive, what’s after the : is a directory, or a folder list that resides on that drive. A drive is also known as a Hard Drive. It is possible to have drive partitions within one hard drive to make that single drive appear to the computer as two separate hard drives. In this case, when you mounted or plugged in your hard drive to your computer, it would show up as F: and G:, not just F:. On Windows computers, most of them now come with C: and D:. This isn’t physically two different hard drives, this has been made with a hard drive partition. Technically (read: usually) your computer will start assigning drive letters at E: and continue down the alphabet for each new connected hard drive. It does get confusing when you start mounting multiple hard drives, because one day it may show up as the G:, and the next day it may be the I:.

On a Linux system, this drive will get mounted as /dev/sdf (or /dev/xvdf on AWS instances).

Hard Drive vs. Virtual Drive

If you’re really getting fancy, you can create a Virtual Drive using a tool like Daemon Tools. This is handy when you have what’s known as an image file (a standard file format is *.iso). It is basically a snapshot of a drive or disc that gets saved into an *.iso file. You can then virtually mount that *.iso using Daemon Tools to view that entire original disc just like it was actually plugged into your computer. Almost exactly the same as what happens when you put a disc into your computer. Virtual drives are powerful because they’re usually ‘read only’, which means you can only read it, you can’t write files to it. So, things like DVDs or Video Games are often downloadable as a *.iso, which you mount using Daemon Tools, and carry on just as you would have if you put the DVD into your computer. After you’re done with it, you unmount and can go so far as to delete the file without actually having to throw a DVD out. We like less waste.

Root & Branches

The root of your directory is the base of the tree (there’s an analogy there). If you think of your C: as the base of your tree, you can imagine all of the folders within it branching out as you go deeper into each folder. So, let’s say inside the C: you have 10 folders, and in each of those folders you have another 10 folders,. We’re now at 100 folders. Inside of each of those 100 folders you have another 10 folders,. Now we’re at 1000 folders. Like a tree, the further you go up, the more branches you have. Always at the end of your folder digging you’ll find files, which you can think of as leaves or berries. The files hold the information, the folders just organize things.

The root is important to know because its basically the first door your computer is faced to look into, that is, is it C:? D:? E:? The root of the E: would just simply be E:\. While writing computer code, if you don’t explicitly define the root – like C:\python\program1\ – then you have to depend on the Operating Systems natural way of searching. A typical way you could expect this is to be local within the folder you’re working in, and then digging into the System Environment PATH locations. This is handy sometimes, but typically, to avoid any sort of confusion, it is very smart to define exactly where you want your program to run from.

It gets a bit tricky when we’re talking about programs here though, because the root folder for a program could just be the first folder for that program. So, if I’ve installed Microsoft Office on my computer, the root folder of that would be C:\Program Files\Microsoft Office. On older versions of Windows it was easier to see this location, but still can by clicking on the address bar in the top of your Explorer window that will automatically revert back to this format, as shown below:

Microsoft Office Folder

Microsoft Office Folder

Local vs. Remote or External Drives

Every computer that is out there today has local hard drives inside of it. Local to the computer. Remote in this sense means not packaged directly inside of the computer, so external. A USB stick is a remote or external drive, your internal hard drive is local.

Your operating system runs on your local hard drive, no matter if it’s Mac, Linux, or Windows. You can do some fancy business by having an operating system on a USB stick and booting your computer onto that, which wouldnt’ be local, but that’s also another discussion for you advanced nerds out there.

Typically on Windows computers, the operating system resides in the C:\. On Linux, the operating system resides somewhere in the /etc/ folder, but also spreads out to many other folders, that is, anywhere under /. On a Linux machine, you have the capacity to manually mount a hard drive that you’ve attached to it (technically you can also do this on Windows). On a Linux machine, you can find the attached drives or devices under the folder /dev/. Depending on the year and the OS, the newly attached hard drive will show up as something like /dev/sdf , sdf being the name given to that now attached drive. So, using the command:

sudo mount /dev/sdf /myDrive

You give a name to your external hard drive “myDrive”, and reference it that way.

Permissions and Users

Operating Systems today are getting smart in that they make various levels of permissions to do various operations on your computer. For example, if you want to install a program, you usually need some kind of Super User or Administrator/Admin permissions to do so. If you’re not an Admin on your computer, your computer will prompt you to enter your username and password to install a program, or flat out deny you ability to install a program. Some of you may have seen this. It’s saying: “You’re doing something that will make some serious changes to your computer, are you super sure you want to be doing this?” This is a good feature that’s been around for a few years now. Some of us may have nostalgia about the first time, years ago now, being prompted upon start up to pick a user you wanted to log in as. It marked a big change in computing.

This all means that generally, your user isn’t an Admin. It’s kind of good so that you can’t do too much damage to your computer if you’re just messin’ around, but a pain in the arse if you’re trying to install any new programs. Your program wont install, and you’ll be told you don’t have proper permissions to do so.

As the Admin , installing programs, you’re usually asked if you’d like to make the program available to specific users on the computer, or only to the Admin. This means that as the Admin of a computer, you can specify who can read (r), write (w), or execute (x) specific files and folders.

  • Reading means you can view the contents of the file, but not edit them.
  • Write means you can read the files, and also change the files and save them with the new content in them.
  • Execute means that you can run the files, so it’s really only relevant for program files, not really text files.

So let’s say I’m working as User1, and I’m trying to edit a Word document, but I’ve only got read permission on the file. When I go to save it, I’ll either get an error saying I do not have permissions to save that file, or to save it as a new file. Saving it as the old file name will not be allowed, User1 won’t be allowed to do that because it doesn’t have the right permissions.

Understanding this, one can see how certain security features could be added to files that are being shared among various people. This is also the basis of how file repositories work, specifically online clouds like Google Docs. If one person is editing the file, it’s locked to only Readable for anybody else with access to it. They can read it still, but they can’t make changes to it. Google Docs have become pretty powerful now, in that you can actually see edits being made in real time to documents that this locking has almost become invisible.

Home Directory

Home Folders

User’s Home Folders

Each user has a home directory. They load unique for each user. So, unique users will have unique Music, Pictures, Videos, Downloads, etc. folders. Remember, the Admin user will have access to all of these folders, but other users on the same computer will not be able to change other users’ files. Other users may be able to dig and read them, so it’s not enough to depend on this level of file security by just changing users. File encryption is highly suggested here.

Each operating system will have a different technical definition of Home Directory, but usually it’s with respect to the specific user. This term is more of a Linux or Mac term, and the home directory is actually labelled as home: /home/user1/. So, inside the folder /user/ will be the home directory for that user.

This term could also be applied to the home directory for a program, such as /etc/nginx/, or C:\\Program Files\Microsoft\.

Windows vs. Linux and Mac OS

All of this gets a bit complicated when you switch operating systems. Above I’ve mostly referenced a Windows Operating System. However, Linux runs much the same, except for assigning drive letters.

Instead of drive letters, Linux and Mac usually assign a name and load it into the /dev/ directory.

For example, when you plug in your USB stick to your Windows computer, it will automatically mount as, let’s say, F:. When you plug in your USB stick to your Linux computer, it will automatically mount as just the USB sticks name (which might be something like ‘Seagate Backup Plus Drive‘) which will show up on the desktop, and also inside the dev folder as: /dev/sdf.

Formatting, Encrypting and Naming Drives

Formatting a drive means that you’re re-writing the entire drive structure to be like a clean slate. You’re erasing all the content and leaving it empty. Like painting a wall, emptying out the garbage can, or even buying a new hard drive. New hard drives usually come pre-loaded with a bunch of files though, some will be security programs, some will be technical documents, some will be backup programs. It’s up to you if you like to keep all this stuff, but I prefer to use my favorite programs instead of the supplied ones.

I now encrypt all of my hard drives using VeraCrypt software. They have extensive documentation on how and why. Encryption must be done before you put anything on a hard drive. When you encrypt a hard drive, it also formats it with the option to give it a name. But generally, when you mount the encrypted hard drive you assign it a name then, and mounting is the necessary step for encrypted hard drives because when you mount an encrypted hard drive, it then prompts you for the password to unlock the encrypted hard drive. This is same for Windows and Linux.

If you’re formatting your drive, you can give it a name of your choosing, but most folks who get a new USB drive just plug it in and go right on using it as it came from the factory.

As discussed previously, when you mount a hard drive in Linux, you can mount it with any name you wish. Mounting doesn’t re-name the actual hard drive itself, nor does it format it, it just gives an additional reference name to that device that your computer will recognize.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

4 + six =