Linux vs Windows File System Structure
If you worked with Windows before, you most likely saw the C:\ local disk. Probably the second local disk named D:\, E:\, F:\, G:\ or something similar and they are represented as Disk Drive. When it comes to Linux, disk partitions are kept in /dev/sd* path(will come to this shortly). Generally, C:\ disk is meant to be used for system files, applications, tools and so on. Users are tend to use other local disks(D:\, E:\…) to install games, store media thus, for personal files. A:\ and B:\ disks are allocated for floppy disks.
In Linux however, file system structure is different. It is more like a logical structure, rather than a physical one and the structure layout is similar to a Tree Data Structure. In Windows, disks can be divided into two or more and have their own roots. “\” character in C:\ points the root of C: disk. In Linux however, there is only one root node which is “/”(Notice the forward slash, in Windows it is “\”). Unlike Windows where can be many roots, there is only one single node where all files be bind to. Every directory spans from the root node. Deepening the tree structure.
Directories and Their Usages
Every child directory of the root node contains specific files. I’m going to explain which folder stores which files and their usages:
This directory has the common applications shared by the system, user and the administrator. Binary files stored here and the commands that you use in Linux Terminal are stored in here, such as “pwd“, “cd“… (For the relevant course -> Here)
When you boot your Linux computer, this directory will come in play. Bootup files and kernel(vmlinuz) are kept here. In some recent distributions also GRUB data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.
The boot loader(Grub or Lilo) needs to load the kernel so that it can start the OS. The reason why the kernel is named vmlinuz is, it is compressed with GZIP. And if you ask why OS Designers chose to compress the kernel, in most computer rigs, the processor can decompress faster than the I/O system can read. By having less for the I/O system to read, you reduce the time needed for boot.
The other benefit is, in embedded environments where storage size efficiency is important, compressed kernel takes less space in non–volatile storage.
You remember when I said “When it comes to Linux, disk partitions are kept in /dev/sda path”? This place contains references to all the CPU peripheral hardware, which are represented as files with special properties. Also where all hard drive partitions are kept. This directory is equivalent to “My Computer” in Windows, where you can see all disks(C:\ …).
The “et-see” directory where configurations are stored. For the configurations affecting all system, this is the place. But if configuration affects only a certain user, file will be kept in /home directory. This directory contains data similar to those in the “Control Panel” in Windows.
This is where your personal files are kept. You are going to spend most of your time here. The Desktop, Documents, Downloads, Photos, and Videos folders are all stored under the /home/username directory. Tilde ~ character points to these directory in terminal(cd ~, ls ~ …).
Libraries for users and system are allocated in this directory. For example, “pwd” command’s library files are kept in here. When you install Linux software packages or additional libraries, you’ll notice that their name are almost always start with lib keyword. These are the libraries for Linux to work properly. Kernel modules are also stored in here. The difference between “Program Files” in Windows and /lib/ directory is that in Linux, libraries are shared between applications. In Windows, applications have their own specific libraries, even if they are redundant. So at the end, Linux is more efficient when it comes to libraries.
This directory contains subdirectories which are used as mount points for removeable media such as floppy disks and CD-ROMs. This varies between different Linux distros.
This directory is a temporary mount point and basically a placeholder, used for mounting. Difference between this directory and dev/sda or /media is, you use this directory to only mount a device under certain circumstances, and at other times have it not readily accessible. For example, when you wish to mount an entire file system for system repair, you place the disc image(e.g. foo.iso) here.
Optional software for your system that is not already managed by your distro’s package manager. Typically contains extra and third party software.
A virtual file system containing information about system resources. /proc is very special in that it is also a virtual file system. It can be regarded as a control and information centre for the kernel. In fact, quite a lot of system utilities are simply calls to files in this directory. The file proc.txt discusses the virtual file system in detail.
This is the equivalent to the /home folder specifically for the root user, also called the superuser. May be determined by developer or local preference, but this is the recommended default location. Mind the difference between “/”, the root directory and /root, the home directory of the root user.
Similar to /bin, except that it’s dedicated to use by the system and the system administrator. /sbin also contains binaries essential for booting, restoring, recovering, and/or repairing the system in addition to the binaries in /bin.
This is where temporary files are stored, and they are usually deleted upon shutdown, which saves you from having to manually delete them like required in Windows. Don’t use this for saving any work!
Contains files and utilities that are shared between users. Programs, libraries, documentation etc. for all user-related programs. /usr is the second major section of the filesystem. It is shareable, read-only data. That means that /usr should be shareable between various FHS-compliant hosts and must not be written to.
If you are a developer, devops, system administrator, network engineer, basically someone working on UNIX computer, you are going to spend some time here. Logging files are kept in here. It is also a storage for all variable files and temporary files created by users, such as the mail queue, the print spooler area, space for temporary storage of files downloaded from the Internet, or to keep an image of a CD before burning it.