The Linux filesystem structure is somewhat different from that of Windows in that Linux doesn’t make use of a physical drive, such as the C: drive, as the base of the filesystem but rather, uses a logical filesystem .
Logical vs Physical Files
Logical Filesystems
Logical files do not contain data. They contain descriptions of records that are found in one or more physical files.
- It does not occupy memory space.
- It does not contain data.
- It can contain up to 32 record formats.
- It cannot exist without physical file.
- If there is a logical file for a physical file, the logical file can be deleted without deleting the physical file.
- CRTLF command is used to make such object.
Physical Filesystems
Physical files contain the actual data , in only one record format, as well as a description of how data is to be presented to or received from a program. Best understood as a collection of bytes on a disk.
- It occupies the portion of memory;
- It contains the original data;
- It can exist without logical file;
- If there is a logical file for physical file, the physical file cannot be deleted until and unless we delete the logical file; and
- CRTPF command is used to make such object.
Linux Filesystem Structure
Probably the best way to understand the Linux filesystem is to explore it through the terminal window in order to see the map of Linux’s directory tree.
Install tree by doing the following on Ubuntu:
Apt-get install tree
Now open a terminal and run tree :
tree -L 1/
The command above instructs the terminal to “show only the 1st Level of the directory tree starting at / (root)“. The “-L” option tells tree how many levels down you want to see.
The top of the file- system structure is “ / ”, which is the root of the filesystem and is different from the root user and the following, from top to bottom, are the most important subdirectories to know:
/bin
Where application binaries, the equivalent of executable files, reside. These are the programs you can run as well as other basic tools for making and removing files and directories, moving them around, and so on. There are more bin directories in other parts of the file system tree.
/boot
The /boot directory contains files required for starting your system. If you mess up one of the files in here, you may not be able to run your Linux.
/dev
/etc
/etc contains system-wide configuration files that you should avoid tinkering with unless you know what you are doing. The contents of this folder include:
- Files that contain the name of your system;
- Users and their passwords;
- The names of machines on your network; and
- When and where the partitions on your hard disks should be mounted.
/home
/lib
/lib is where you find libraries, which are shared programs similar to Windows DLLs. Libraries are files containing snippets of code that applications use:
- To draw windows on your desktop;
- Control peripherals; or,
- Send files to your hard disk.
Additional lib directories EW scattered around the filesystem, but the one directly off of “/” contains the all-important kernel modules, drivers that make things like your video card, sound card, WiFi, printer, and so on, work.
/media
/mnt
The /mnt directory, where other filesystems are attached or mounted to the filesystem however, is a bit of remnant from days gone by. This is where you would manually mount storage devices or partitions. It is not used very often.
/opt
/proc
/root
/run
/sbin
/sbin is similar to /bin, but it contains applications that only the superuser will need. These applications can be used by regular uses with the sudo command that temporarily concedes you superuser powers on many distributions. This folder contains tools that can install, delete and format files.