Linux File System Explained with Shell and Kernel

This tutorial explains fundamental and basic concepts of Linux File System structure, Shell and Kernel step by step. Learn what is LFS (Linux File System), Shell and Kernel and how they works in Linux including Linux File & Kernel naming convention and common Linux system directories in detail with examples.

A Linux system is basically divided in three major components: File System (LFS), Shell and Kernel. Kernel is the core program which manage 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.

Linux File System

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 starts file system with root directory(/). All files and directories are created and managed under the root directory. Since root directory stands on the top in file system, it has no parent directory. Besides root directory, every directory in Linux 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 common system directories with their location in LFS.

Linux System Directory tree

Common System directories

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. Whenever user login, Linux starts his login session from home directory.
/root This is the home directory for root user. Root user is the super user in Linux. For security reason Linux creates a separate home directory for root user. Root user account is also being created during the installation automatically.
/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 root user and usually requires 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 file.
/mnt This directory is used to mount 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.
Practical Example

List all directories from root directory.


ls / command will list all directories from root directory.

listing root directory

Linux File Naming Convention

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

Key points
  • A Linux file name may have any characters or letters.
  • Maximum length for file name is 256 characters.
  • File name can use space, underscore, minus, period and comma.
  • File name cannot use question marks, asterisks and slashes.
  • File extension is not compulsory. We can create files with file extension or without file extension.
  • To create a hidden file, start its name with dot.
  • If file name has spaces, it need to be quoted before we can access it on command prompt. On desktop we can use it without quotes.
Practical Example
  • Create a test directory
  • Move in the directory.
  • Create blank files with following names:-
    test, test.doc, test.docx, test-file, test_file, test.file, test file (‘test file’ at command prompt), .test-file (hidden file)
  • Verify the file creation.
  • Verify the hidden file.
  • Exit from directory
  • Delete the directory.

linux file name

  • Create new directory from mkdir command.
  • Use cd command to move in directory.
  • Use touch command to create files. touch command creates blank file. It accept multiple files name. File name would be separated by a space. Shell use space to parse arguments on command line. We can create multiple files with single command by separating file names with space. If a file name has space in it, we have to quote it.
  • To create a hidden file start its name with dot (.).
  • Use ls command to list the files of current directory.
  • Use ls command with –a option to list hidden files.
  • Use cd .. command to return in parent directory.
  • Use rm –rf command to delete the directory with all files.


Shell is a command interpreter. It take commands from user, execute them and display the results. Shell supports I/O ( Input / Output) redirection which means it can read commands from non-standard sources such as script files. As well as it can also redirect output to any supportive device (such as printer) or data server.

Several Shells are available in Linux such as Kom, TCSH, Z shell, Bash etc. Although several shells are available, only one shell is set to default in RedHat Linux. Bash (Bourne Again shell) shell is the default shell in Red-Hat Linux.

Command Description
cat /etc/shells To list the all available shells
chsh –l To list the all available shells
echo $0 To view the current shell name
exec /bin/csh To change current shell temporary. At next login default shell will be restored.
chsh –s /bin/csh To change current shell permanently. Change will be applied at next login. Default shell will be used in current session.
Practical Example
  • View the current shell and list all available shells.
  • Change current shell temporary for this login session and verify the change.
  • Logout from current session and login again and verify that default shell get restored.
  • Change shell again but this time change it permanently.

To view the current shell use echo $0 command. To list all available shells either use cat /etc/shells or use chsh –l command.

list available shell in linux

To change current shell temporary use exec /bin/csh command. This command will change current shell to csh. This change will be temporary. It will be lost with current session. To verify this terminate the current session with exit command.

Login again and view the current shell. It should be restored with default shell.

how to change shell in linux temporary

To change the current shell permanently use chsh –s /bin/csh command. Change will take place at next login.

change shell paramanently


Kernel is the core application in Linux operating system. It communicates directly with system devices such as memory, CPU, CDROM, Hard disk etc.

linux kernel

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

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 versions will first available as release candidates. Release Candidates (rc) are intended for developers. RC allows developers to test new features of kernel before final version is released. Release candidate have an indicative keyword (rc) in name for example kernel-2.6.22-rc3.

Kernel is an open source project. Distributors are allowed to make changes in kernel. If distributor makes any change in kernel, he will add a patch number in the end of the name. Besides patch number, distributors may add platform number.

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

linux kernel

That’s all for this article.

ComputerNetworkingNotes RHCE 7 Study Guide Linux File System Explained with Shell and Kernel