Linux File System and Kernel Version Explained

This tutorial explains Linux file system structure (Linux directory structure) along with the naming convention used in kernel version. Learn how the Linux file system is organized including the meaning of important high-level directories in detail.

A Linux system is basically divided in three major components: Linux File System (LFS), Shell and Kernel. Kernel is the core program which manages system hardware devices. Shell provides user interface to run the commands. File system organizes the data in systematic way. Collectively LFS, Shell and kernel provides a way to interact with system and an environment to run commands and manage data.

shell kernel linux example

Let’s understand these components in more details one by one.

Linux File System (LFS)

Linux accesses every object as file. Files are systematically organized in directories. Linux file system starts with the root (/) directory. All files and directories are created and managed under this (root) directory. Since root directory stands on the top of file system, it has no parent directory. Besides root directory, every directory has a parent directory. Linux allows us to create as many files and directories as we want. We can create files under the existing directories or may create new directories.

System Directories

System directories contain files, software, applications and scripts which are required to run and maintain the Linux. System directories are automatically created during the installation.

Following figure illustrates some important system directories with their location in LFS.

Linux file system

Linux Directory Structure (File System Structure)

Directory Description
/ First directory in Linux File System. It is also known as root directory or main directory. All files and directories are created and managed under this directory.
/home Default directory for user data. Whenever we add a new user, Linux automatically creates a home directory matching with his username in this directory. Linux puts user in his home directory just after the login.
/root This is the home directory of root user. Root user is the super user in Linux. For security reasons, Linux creates a separate home directory for the root user.
/bin This directory contains standard commands files. Commands stored in this directory are available for all users and usually do not require any special permission to run.
/sbin This directory contains system administration commands files. Commands stored in this directory are available only for super users and usually require special privilege to run.
/usr This directory contains user application software files, third party software and scripts, document files and libraries for programming languages.
/var This directory stores variable data files such as printing jobs, mail box etc.
/etc This directory contains system configuration files.
/boot This directory contains Linux boot loader files.
/mnt This directory is used to mount the remote file system and temporary devices such as CD, DVD and USB.
/dev This directory contains device files. Usually files in this directory are dynamically generated and should be never edited.
/tmp This directory provides temporary location for applications.

Linux File Naming Convention

Unlike Windows operating system, Linux is not strict with naming convention. We can use any number or letter in file name. We can also use underscore, space, period and comma. Some special characters such as question mark, asterisk and slash are not allowed in file name. These characters are reserved for shell functions. Just like Windows, we can use dot to create a file extension. Although file extensions are not compulsory in Linux, still they should be used wherever possible as they provide a good way to manage the files.

Key points
  • A file name can contain any character or number.
  • Maximum length for the file name is 256 characters.
  • File name can use space, underscore, minus, period and comma.
  • File name cannot use question mark, asterisk and slash.
  • File extension is not compulsory. A file can be created with or without extension.
  • A file which name starts with a period (.) is treated as a hidden file.
  • If file name contains whitespace, it needs to be quoted before it can be accessed at command prompt.

Shell

Shell is the command line interpreter. When a user wants to access any device, he types appropriate command at shell prompt. Shell interpreters that command and hands over the instruction to kernel. Kernel communicates with device and process the user request.

how shell and kernel communicate

Shell is explained in detail with examples in second part of this tutorial. This tutorial is the first part of the article "Linux file system and shell explained with file redirectors". Other parts of this tutorial are following.

Linux shell and command types explained

This tutorial is the second part of the article. It explains shell and its function in detail along with Linux command types such as internal commands, external commands, non-privileged commands and privileged commands.

STDIN, STDOUT, STDERR and File redirectors explained

This tutorial is the third part of the article. It explains what the STDIN, STDOUT, STDERR and File redirectors are and how they work in Linux with examples.

Kernel

Kernel is the core application in Linux operating system. It understands both high level programing language which shells use and low level machine language which hardware devices use. It stands between the shell and hardware devices. It takes commands from shell and converts them in machine language before executing them on hardware. Vice versa, it takes output from hardware devices and converts that in programming language before providing to the shell.

Understanding kernel version

Kernel name provides information about its version. Kernel version number is built from four segments; major, minor, revision, and security / bug fix.

  • Major number: - This number reflects major changes in kernel.
  • Minor number: - This number reflects a major revision in kernel.
  • Revision number: - This number reflects that new supporting features are added in kernel.
  • Security/ Bug number: - This number reflects security or bug fix in kernel.

Kernel development is an ongoing process. Development version is released before the main version. Development version is known as Release Candidate (rc). It is intended for developers. It allows developers to test new features of kernel before they are made available for all in the final version. Release candidate have an indicative keyword (rc) in name for example kernel-2.6.22-rc3.

Since Kernel is the open source project, distributors are allowed to make changes in it. If distributor makes any change in it, a patch number will be added in the end of the name. If kernel is patched for particular hardware architecture, an indicative name of that architecture will also be added just before the patch number.

  • To view which kernel package is install, use rpm –q kernel command.
  • To view only the kernel version number, use uname –r command.

kernel version number explained

That’s all for this part. In next part, we will understand the shell and its functions in detail. If you like this tutorial, please don’t forget to share it with friends through your favorite social platform.

ComputerNetworkingNotes RHCE 7 Study Guide Linux File System and Kernel Version Explained