Linux File System

Linux Kernal

The linux kernal ensures coordination between harware and software. This role includes managing hardware, processes, users, permissions, and the file system. The kernal provides a common base to all other programs on the system and typically runs in ring zero, also known as kernal space.

Driving Hardware

The kernel is tasked first and foremost with controlling the computer's hardware components. It detects and configures them when a computer powers on, or when a device is inserted or removed.

The programming interface also provides an abstraction layer; this allows video-conferencing software, for example, to use a webcam regardless of its maker and model.

The software can use the Video for Linux (V4L) interface and the kernel will translate function calls of the interface into actual hardware commands needed by the specific webcam in use.

The kernel exports data about detected hardware through the /proc/ and /sys/ virtual file systems. Applications often access devices by way of files created within /dev/. Specific files represent disk drives (for instance, /dev/sda), partitions (/dev/sda1), mice (/dev/input/mouse0), keyboards (/dev/input/event0), sound cards (/dev/snd/*), serial ports (/dev/ttyS*), and other components.

There are two types of device files: block and character.

Block Device Files: Has a finite size and you can access bytes at any position in the block.

Character Device Files: Behaves like a flow of characters. You can read and write characters, but you cannot seek to a given position and change arbitrary bytes.

To find out the type of a given device file, inspect the first letter in the output of ls -l. It is either b for block or c for character.

Device Files have device-specific commands that can be invoked throug the ioctl system call.

Unifying File Systems

File systems are a prominent aspect of the kernel. Unix-like systems merge all the file stores into a single hierarchy, which allows users and applications to access data by knowing its location within that hierarchy.

Unlike other systems, Linux possesses only one file hierarchy, and it can integrate data from several disks. One of these disks becomes the root, and the others a mounted on directories in the hierarchy (the linux command is called mount). These other disks are then available under the mount points. This allows storing users' home directories (traditionally sotred within /home/) on a separate hard disk, which will contain the kali directory (along with home directories of other users). Once you mount the disk on /home/, these directories become accessible at their usual locations, and paths such as /home/kali/Desktop/hello.txt keep working.

Managing Processes

A process is a running instance of a program, which requires memory to store both the program itself and its operating system. The kernel is in charge of creating and tracking processes. When a program runs, the kernel first sets aside some memory, loads the executable code from the file system into it, and then starts the code running. It keeps information about this process, the most visible of which is an identification number known as the process identifier (PID).

Multi-Processor Systems (and Variants)

There can only be one running process per processor core. Multi-processor, multi-core, or hyper-threaded systems allow several processes to run in parallel.

Rights Management

Unix-like systems support multiple users and groups and allow control of permissions. Most of the time, a process is identified by the user who started it. That process is only permitted to take actions permitted for its owner.

The User Space

The term user space is used to lump together everything that happens outside of the kernal. Among the programs running in user space are many core utilities from the GNU project, most of which are meant to be run from the command line.

Last updated