Tuesday, January 31, 2017

Linux File System Explained With Shell And Kernel

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.


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.

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.
/rootThis 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.
/binThis 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.
/sbinThis directory contains system administration commands files.
Commands stored in this directory are available only for root user and usually requires special privilege to run.
/usrThis directory contains user application software files, third party software and scripts, document files and libraries for programming languages.
/varThis directory stores variable data files such as printing jobs, mail box etc.
/etcThis directory contains system configuration files.
/bootThis directory contains Linux boot loader file.
/mntThis directory is used to mount remote file system and temporary devices such as CD, DVD and USB.
/devThis directory contains device files.
Usually files in this directory are dynamically generated and should be never edited.
/tmpThis directory provides temporary location for applications.

Shell :

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.
CommandDescription
cat /etc/shellsTo list the all available shells
chsh –lTo list the all available shells
echo $0To view the current shell name
exec /bin/cshTo change current shell temporary. At next login default shell will be restored.
chsh –s /bin/cshTo change current shell permanently. Change will be applied at next login. Default shell will be used in current session.

Kernel

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


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 distributer 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.

0 comments:

Post a Comment