File-system Structure

So there are no drive letters, but there are partitions. All good. But how do you know where to look for your files? Like your collection of family pictures, your work documents, and not least those nasty videos you’ve downloaded from the internet. (Now wondering, how the hell did I know about them, aren’t you?) 😉

Linux has a fundamentally different approach towards file storage and file system structure, but from the user’s point of view, it can appear to be quite similar, and so it does in most modern distributions. To give you an idea of the basics:

There is a root folder, that is marked with a “forward slash” symbol, or /. (Not to be mixed with the /root folder, which is something to do with the root user, which will be covered in the next post).

In Linux, the word “root” is used extensively, yet it has nothing whatsoever to do with plants…

The root folder (/), is where everything “originates”. Sort of. Inside this folder, you will find many others, but only some of these will be interesting from a user’s point of view. The most important, and which you really want to know about at this point is the /home folder, that contains sub-folders for any user account, that was created on the system (Much like Windows’ “C:\Users“, or “Documents and Settings“.

For example, if your username is beowulf, your user home folder will be /home/beowulf. This means, the “home” folder found on “/“, contains a folder called “beowulf”. The forward slash symbol at the beginning means “root”, and after that, every time you see it, it will be a sort of divider between folder and file names.

Inside your user home, you will probably have the usual sub-folders, like “Documents”, “Music”, “Videos”, etc. So if you want to access your audio files, you would look for them in /home/beowulf/Music. Simple as that. And the good news is, there are plenty of very easy-to-use graphical file managers to choose from, and most of them make the process even simpler. Upon starting, they’d bring you right to your home folder, where you will see the usual set of icons and file previews

The Dolphin file manager from KDE

Of course, there is life beyond the home folder on Linux. For many users these are totally transparent, i.e. if they did not exist, you would never notice (the folders, not the users… or, well, probably both). Anyway, if you are interested in digging a little deeper inside the Linux file system, you will soon find, that from / there are a lot of other sub-folders originating. Some of these might even be sitting on a separate partition, as is quite usual with the /home folder itself (thus becoming, in reality, a “home partition”, but from the user’s point of view, there is no real difference). Some of the important ones include

  • /usr, and more specifically /usr/bin, which usually holds all the application executables. So if you are looking for an app to start, but cannot find the “icon” for it, there is a good chance you can start it from here.

  • The /etc folder has all sorts of system and application configuration files. Very often some more advanced Linux tutorials will reference this location, so it is good to be familiar with it.

  • /media is often used as a default mount point for removable devices, like USB drives

  • And there is, of course, the good old /dev, which holds all your devices’ file-like representations (more on that below).

  • Not to forget about /root, which serves as a home directory for the “root” user (see next post), or

  • /boot, that has all the necessary files for system start-up.

There are of course many others too, but who can remember all those weird names and labels anyway…

Everything is file…

In Linux this is one peculiarity, that can be a little difficult to wrap your head around because, by everything, we mean everything. Folders, files, system processes, devices, even the hard disks, are represented in the file system in one way or another. OK, the statement, is not strictly true, because they are not all treated as files, so it  would be better to think of it as “everything is represented as part of the file system”. Quite fortunately, you will not need to know how it works, but it is important to know this, when you read tutorials that reference something in /dev, which means “device”, and has a representation to all hardware devices in a system (or most).

No file extensions?

Another peculiarity of Linux, compared to Windows is that file extensions are not mandatory. You can have them, and it certainly makes identifying the file type a lot easier, but they are not required. This means a file called ToDo.txt and another called just ToDo will behave the same (like a text file) when they contain only text. In other instances, you must have a file extension, but not because of Linux, but rather because the software you use mandates it.

Still, Linux is capable of recognising the file type in other ways, so if you rename e.g. MyDocument.doc to just MyDocument (i.e. remove the extension), you can still open it in your favourite word processor (which, when we are finished with your indoctrination, will be LibreOffice).

Interestingly, the same would not work with the docx format. Linux still recognises the file type after you removed the extension, but treats the file for what it is: a zip archive. In case you did not know, docx is a re-branded zip archive, which holds several xml files, and other resources, like image attachments, which make up a docx document. Linux recognises the archive, and opens the extension-less docx in an archive manager, rather than a word processor, making it a good example of how file name extensions can be important

So how can you differentiate between files and folders? That’s a bit trickier… Fortunately, the system knows the difference, and file browsers and file explorers know it too, so it will be marked with different icons, just like on Windows. on the command line, file listing tools will usually mark them with different colours, although this largely depends on the tool in use.