For those of you coming from windows backgrounds, the way the Linux filesystem is laid out may seem confusing at first glance…. but that is where this article comes in!
The first thing you should know when working with Linux, is that everything is treated as either a file or directory. Yes that’s right, even hardware is considered a file by Linux, and, speaking of hardware… all your hardware devices are located in the /dev directory, but more on that later.
Another thing that confuses windows users, is the fact that Linux doesn’t use drive letters to distinguish between different partitions and devices. that is to say in Linux, the “root” of your filesystem is / whereas in windows it would most probably be C: . Drives in Linux are “mounted” to directories where their data can then be accessed, so for instance, if you needed to use your thumb drive, you would plug it into your computer, and then mount it using the “mount” command, which specifies the path to the device ( something like /dev/sdb or /dev/sdc ) and the directory to mount it to (usually /mnt or /media), then you can happily access your drive from the /mnt or /media folder.
Sounds strange right? well yes it does if you come from a windows environment, where the entire operating system is consolidated onto a single drive. However, with Linux and the ability to mount devices as directories, it gives the end-user much greater flexibility in splitting up their operating system over several drives or partitions.
to understand what I mean when I say that this approach in mounting drives grants flexibility, I must first explain the different folders in Linux and what they storeDiagram showing Linux filesystem hierarchy
The graphic above shows the Linux filesystem hierarchy, now will explain in a bit more detail what each folder contains.
/ this is the root folder, all other folders come under root.. think of it as C: in a Windows context.
/bin this folder contains all the user-essential binaries (programs) that are needed to administer and run your Linux system… delete this folder and your system is broken.
/boot as the name suggests, this folder contains configuration files and other necessary files that are needed by the boot loader
/dev this folder contains device files (remember, these files represent physical devices, so be careful when working with them)
/etc this folder contains all the configuration files used by the system, you can also start and stop services (daemons ) from here
/home this folder contains the home folders of all the normal (non – root ) users on the system .. think of it as my documents in windows
/lib this folder contains software libraries
/media this is a mount point for removable devices… this is where you would usually mount your thumb drives… etc
/mnt this is a temporary mount point
/opt this folder contains add-on software (extra software)
/sbin this folder contains binaries that can only be run as the root user (“superuser”)
/tmp this folder contains temporary files that are erased upon reboot
/usr this folder and its sub folders contains user installed programs and utilities and libraries
/var this folder contains files that change a lot (“Variable files”)
/root this folder contains the root user’s files
/proc this is a pseudo folder, that contains information about the Linux kernel and hardware that is updated in realtime.
Now back to how mounting grants flexibility…
you see how the different folders all contain parts of the operating system? well we can actually mount a separate hard drive for each of this folders. for example, your /home folder can be put on another hard drive than your / which means that you can easily recover your personal files if the hard drive on / fails because the hard drive mounted to your /home folder is separate from the one that is mounted to your /
So there you have it, you now know a little bit more about the nuts and bolts of Linux based operating systems. I hope now you know about Linux file systems, EXT3, EXT2 and FAT32.