Kernel
Kernel
Kernel
Layer-1: Hardware-This layer consists of all the hardware resources being used.
Layer-2: Kernel -The kernel is like the heart of the operating system. It is the mode
of interaction between the hardware and the operating system. It also manages tasks
and resources using scheduling processes for the smooth functioning of the system.
Layer-3: Shell commands -It is how a human interacts with the operating system and
tells it to start certain processes. An interpreter is used where we give the command
for the operating from the set of all commands for which the definition has been
defined and stored in the libraries.
Some examples of commands are cp, mv, cat, grep, id, wc, nroff, a.out, and more.
Layer-4: Application Layer -It executes the given external applications. It is the
outermost layer to execute the applications.
List of Unix Shell Commands-Here is the list of the following Unix Shell Commands
mention below:
Basic.
Intermediate.
Advanced.
1. Basic Unix Shell Commands
a. Listing files (ls) – ‘ls’ command lists all the files in a directory.
Syntax- ls -<option> directory_name
Example-ls test
option Description
ls -a To list all files with the hidden files starting with ‘.’
ls -ls list with the long format with the file size
b. Creating & Viewing Files – ‘cat command can be used to create the file or view the
contents of the file.
Syntax –cat >filename
Example – cat > test1.dat – will create a file and wait for the input to be written into the file.
cat filname – will display the contents of the file on the screen.
c. Deleting Files -‘ rm’ command deletes a file from the directory.
Syntax-rm filename
Tag Description
Option Description
-type c Returns true if the file being searched is of type c( if c = ‘f’ means it is a file; if it ‘d’,
means it is a directory)
Example – If someone wants to search for file names ‘test1’ in the directory, he should give
a command like –
find –type f –name test1 /abi/sand
– This command will give all test1 file in /abi/sand directory
c. chown – change ownership of the file. Sometimes someone wants to change the file owner
so that someone working on that file can access that file. Only the file owner has the right to
change the file ownership.
Syntax:chown [owner] [file]
Example: Change the owner of test1 to user name ‘aaggasa’, assuming that the current user
currently owns it
> chown aaggasa test1
d. chgrp: change the group ownership of the file. This command is used to change the group
to which the file belongs. Only the file owner has the right to change the file ownership.
Syntax:chgrp [group] [file]
Example: Change the group of test1 to group2, assuming the current user currently owns it.
> chgrp group2 test1
e. Head: Unix gives us this command-line utility to extract the first part of the file. It writes
the result on standard output.
Syntax –head <option> <filename>
Option Description
Option Description
Option Description
Option Description
1. User Mode
The system is in user mode when you use applications like MS Word (mode bit 0). It
switches to kernel mode (mode bit 1) when accessing devices and system calls.
2. Kernel Mode
At boot, the system starts in kernel mode. Applications run in user mode. Switch to kernel
mode happens for interrupts, privileged instructions, and device access. The mode bit
changes from 0 to 1 when returning to user mode.
D. Difference between User Mode and Kernel Mode
Resource Access Direct access to RAM and No direct access; requires a system call for
hardware. access.
Privilege Level More privilege for accessing Less privilege for accessing resources.
resources.
Virtual Address All processes share the virtual Processes share a separate virtual address
Space address space. space.
Restrictions No restrictions; direct access to user Restricted; needs a system call for
and kernel programs. immediate access.
Interruptions System shutdown is possible on Single process failure doesn’t shut down
interruption during execution. the whole system.
System Crash Single-system crashes may lead to A single system crash is recoverable and
complicated problems. doesn’t affect the whole system process.
Functionality You can refer to any memory block Basic; cannot access hardware/RAM
and access resources directly. directly, uses API.
E. Real-life Scenarios
In everyday situations, you may encounter errors generated by the Kernel. For instance, when
attempting to download a file, you might receive an error message (error-1) warning that the
file could harm your computer. This caution from the Kernel is based on its foresight of
potential problems that may arise during the download, or it could be due to the unavailability
of necessary resources for the download process.
F. Types of Kernel in OS
There are five types of kernels, as given below.
1. Monolithic Kernel
Monolithic Kernels handle core computer functions, managing files, memory, and resources.
Examples are Dos, Solaris, and Linux. Monolithic kernels are used for tasks like CPU
scheduling and are known for reliability, security, and speed. All hardware control software is
within the kernel for direct communication. Monolithic kernels can load modules efficiently
and reduce overhead compared to embedded modules.
Examples of Monolithic kernels are Linux, Unix, XTS-400, and VMS.
These are some fundamental differences between Kernel and Operating System.
Loading into Memory Loaded first during system startup The entire system, including the kernel,
is loaded
Responsibilities Core tasks like process scheduling, Includes utilities, libraries, and
resource allocation, etc. interfaces for user interaction