CYB 203 Note 2
CYB 203 Note 2
networking protocols.
HOST
CP
Gateway Local Area Network
(LAN)
HOST
COMMAND INTERFACE
command-line
A interface (CLI) isa text-based user interface (UI)used to run programs, manage
with the computer. Command-line interfaces are also called command-line
computer files and interact
user interfaces, console user interfaces and character user interfaces. CLs accept as input commands
prompt are then run by the
that are entered by keyboard; the commands invoked at the command
computer.
Today, most vendors offer the graphical user interface (GUI) as the default for operating systems (OSes)
such as Windows, Linux and macOS. Most current Unix-based systems offer both a command-line
interface and a graphical user interface.
The MS-DOS operatingsystem and the command shell in the Windowsoperatingsystem are examples
of command-line interfaces. In addition, programming language development platforms such as Python
can support command-line interfaces.
The command line dropped in popularity following the introduction of GUI-based personal computer
OSes like Microsoft Windows and Apple's "classic" Mac OS in the 1980s. The command line remains an
important tool for IT professionals, software developers,sys admins, network administrators and many
others who prefer a more precise and reproduceable interface to their systems.
What is a shell?
In computing, a shell program providesaccess to an operating system's components. The shell gives
users (or other programs) a way to get "inside" the system to run programs or manageconfigurations.
The shelldefinesthe boundary between inside and outside.
CLI-based shells offer users a concise and efficient mode of interacting with the 0S, without requiring
the overhead of a graphical user interface.
GU-based shells are considered easier for beginners to use, but they also include a CL-based shell for
system administratorsor power users who prefer to interact at a command prompt.
Bash is the most commonly used command-line shell for Unix-based OSes including Linux.
Shells are the outermost layer of the OS and are often separated from the underlying OS kernel. A shell
operates like an application and can be replaced as needed. An OS may have more than one shel
Microsoft Windows includesthe Command Prompt app as well as the PowersShell application, both of
which can be used to interact directly with the computer. The WindowsSubsystem for Linux also
Linux and other Unix-based operating systems usually provide the Bourne-Again Shell (bash) as the
default shelL. Other shells, including the C shell, Z shell and others,can be configured asthe default
system shell.
Because the shell is only one layer above the 0S,users can perform operations that are not available in
other interface types, such as moving files within system folders and deleting locked files.
To get the greatest benefit from using a CLI shell, users should learn a scripting language. Most
command line shells can save sequences of commands in a script or batch file which may be fully
programmable. Shell scripting is the foundation of basic systems management automation.
Once a computer system is running, its CLI opens on a blank screen with a command prompt and
commands can be entered.
system commands that are encoded as part of the operating system interface:
executable programs that, when successfully invoked,run text-based or graphical applications; and
batch programs (or batch files or shell scripts) which are text files listing a sequence of commands.
When successfully invoked,a batch program runs its commands which may include both system
commands and executable programs.
CLI is more than a simple command/response system, as most have additional featuresthat make one
preferable to another. Some features include the following:
1. Scripting capability enables users to write programs that can be run on the system from the command
line.
2. Command pipes enable users to direct the output of one program to be the input for another
3. System variables can be set at the command line, or the values of those variables displayed.
4. Command history features enable the user to recall previous commands issued. Some save command
history for the session (like PowerShell),others can be configured to store session history for longer (like
bash).
5. Commands and syntax for CLIs tend to be very stable over time, in part to enable backward
compatibilityfor scripts.
Depending on the operating system and the CLI, there may be hundreds or even thousands of different
executable commands available. The set of commands may vary dramatically betweenoperating
systems or applications.
PowerShell; PowerShell functions are lists of cmdlets that can be run at the command line.
Some commandsrun at the command line by themselves, such as the dir command:
C:\> dir
Commandscan also be used with arguments (sometimes referred to as parameters)that modify how
thecommand should be run. Arguments follow the command and provide additional details or specifics.
The cd "change directory" command in many CLis is used to change the current working directory when
the desired new directory path is included as an argument -- but in some cases (as in MS-DOSor the
Windowscommand prompt) the command by itself returns the current working directory.
cd \documents\user\working
Arguments enable command-line users to get very specific results that are sometimes not available
Modern CLIs provide pipes, or mechanisms for taking the output of one command and sending it as
input to another command.The vertical bar, or "|"symbol, is often used for this purpose.
The following "one-liner" uses pipes to string together several PowerShell commandsto retrieve
Even though this string is entered at the command line as if it were a single command,it includesthe
following consecutive commands:
Get-NetiPAddress retrieves all IP configuration information for the computer when entered without any
arguments.
Sort interfacelndexaccepts as input the output ofthe Get-NetiPAddress cmdlet and sorts it by the
Interfaceindex value associated with each lP address included in the computer configuration.
format the sorted output of the previous command and displays the specified values for each IP address.
Backward compatibility is often a goal when new CLis are introduced to replace existing CLis, as when
Microsoft replaced MS-DOS with the Windows Command Prompt. Though some MS-DOS commands are
no longer supported, most willstill work in PowerShell as originally intended.
Command Examples
although many GUls allow some navigation and program execution via a keyboard.
Example of MS Os powershelI
CLI
Asdrss/ans ly PASsreis
JA
1P4169.254.J4
19
H0YHiCRaVIMU
Microsoft Word is an example of a GU-based application. A user can change optionsfor page layouts
andstyles by selecting the corresponding icon or pull-down menu with a mouse or keyboard.
One advantage of a GUlis the interface can visually display available functions. However, because it
relies on graphical display, a GUl may not have the same level of functionality and granular control as a
command-line interface. For example, it can require numerous clicks and movement through several
dialog boxes in a GUIto accomplish the same result asa single command line. In addition, GUIs do not
readily support scripting or automation. For common tasks, a user must repeat each click or navigate
each dialog within the GUlmanually.
System administrators who may need to manage hundreds -- or hundreds of thousands -of systems
and configurations will find a GUl far less efficient than a CLI. A simple CLI command can easily adjust
configurations for a large group of systems at once.
Commands and arguments can also be combined and saved, then executed as a script each time that
specific action -or comprehensive set of actions -- is required. The CLI is the preferredtool for many
enterprise-widesystems managementtasks.
Windows 11 GUI: The Start menu
4. basic command-line interface knowledge can enable troubleshootingof network connection issues or
resolving other system tasks.
2. steeper learning curve associated with memorizing commands and complex syntax/arguments; and
different commands used in different shells.
It helps in managing the data present in the device i,e. Memory Management.
A boot loader, also called a boot manager, isa small program that places the operating system (0S) of a
computer memory.When a computer is powered-up or restarted, the basic input/outputsystem
into
(BIOS)performs some initial tests, and then transfers control to the Master Boot Record (MBR) where
the boot loader resides. Most new computers are shipped with boot loaders for some version of
Microsoft Windows or the Mac OS. If a computer is to be used with Linux, a special boot loader must be
installed.
For Linux, the two most common boot loadersare known as LILO (LInux LOader) and LOADLIN (LOAD
LINux). An alternative boot loader,called GRUB (GRand Unified Bootloader),is used with Red Hat Linux.
LILOis the most popular boot loader among computer users that employ Linux as the main, or only,
operating system. The primary advantage of LILO is the fact that it allows for fast boot-up.LOADLIN is
preferred by some users whosecomputers have multiple operating systems, and who spend relatively
little time in Linux. LOADLIN is sometimes used as a backup boot loader for Linux in case LILO fails. GRUB
is preferred by many users of Red Hat Linux, because it is the default boot loader for that distribution.
Bootstrap Loader: More formally called an Initial Program Loader (IPL), a small section of
executable code, permanently stored in a ROM chip within the computer, whose sole function is to load
into memory from DISK justthat small part of a computer's OPERATING SYSTEM needed to load the
remainder of the operating system.
What is a kernel?
The kernel is the essential foundation of a computer's operating system (0s). It is the core that provides
basic services for all other parts of the OS. It is the main layer between the OS and underlying computer
hardware, and it helps with tasks such as process and memory management, file systems, device control
and networking.
During normal system startup, acomputer's basic input/output system, or BIOS, completes a hardware
bootstrap or initialization. It then runs a bootloader which loads the kernel from a storage device -- such
as a hard drive -- into a protected memory space. Once the kernel is loaded into computer memory,the
BIOS transfers control to the kernel. It then loads other 0S components to complete the system startup
and make control available to users through a desktop or other user interface.
If the kernel is damaged or cannot load successfully, the computer be unable to
will start completely -- if
at all. This willrequire service to correct hardware damage or restore the operating system kernel to a
working version.
Kernel layout
Application
Kernel
1. It provides the interfaces needed for users and applications to interact with the computer.
In more granular terms, accomplishing these three kernel functions involves a range of computer tasks,
2. organizingand managing threads and the various processes spawned by running applications;
8
3. schedulingwhich applications can access and use the kernel, and supervising that use when the
scheduled time occurs;
4. deciding which nonprotected user memory space each application process uses;
6. managing and optimizing hardware resources and dependencies, such as central processing unit (CPU)
and cache use,file system operation and network transport mechanisms;
7. managing and accessinginput/output devicessuch as keyboards, mice, disk drives, USB ports,
8. handlingdevice and application system calls using various mechanisms such as hardware interrupts or
device drivers.
Scheduling and managementare central to the kernel's operation.Computer hardware can only do one
thing at a time. However, a computer's OS components and applications can spawndozens and even
hundreds of processes that the computer must host. It's impossible for allof those processes to use the
computer's hardware -such as a memory address or CPU instruction pipeline -- at the same time. The
kernel is the central manager of these processes. It knowswhich hardware resources are available and
which processes need them. It then allocates time for each process to use those resources.
The kernel is critical to acomputer's operation,and it requires careful protection within the system's
memory.The kernel space it loads into is a protected area of memory. That protected memory space
ensures other applications and data don't overwrite or impair the kernel, causing performance problems,
instability or other negative consequences. Instead, applications are loaded and executed in a generally
available user memory space.
A kernel is often contrasted with a shell, which is the outermost part of an OS that interacts with user
commands. Kernel and shell are terms used more frequently in Unix OSes than in IBM mainframe and
Microsoft Windows systems.
A kernel is not to be confused with aBlOS, which is an independent program stored on a chip within a
computer's circuit board.
Device drivers
A key part of kernel operation is communication with hardware devices inside and outside of the
physical computer. However, it is impractical to write an OS capable of interacting with every possible
device in existence.Instead,kernels rely on the ability of device drivers to add kernel support for
When an OS is installed on a computer, the installation addsdevice drivers for any specific devices
detected within the computer. This helps tailor the OS installation to the specific system with just
enough components to support the devices
present. When a new or better device replaces an
existin8
device, the device driver is updated or
replaced.
There are several types of device drivers. Each addresses a different data transfer type.The following
are some of the main driver types:
Character device drivers implement, open, close, read and write data, as wellas grant datastream
access for the user space.
User mode device drivers encompass an array of ad hoc drivers used for aftermarket, user-added
MOITAMAOW0
devices,such as printers, graphicsadapters,mice, advanced sound systems and other plug-and-play
devices.
SMA
YTIBSEVIMU
The 0S needs the code that makesup the kernel. Consequenthy, the kernel code is usually loaded into an
40 area in the computer storage that is protected so that it willnot be overlaid with less frequently used
parts of the OS.
Computer designers have long understood the importance of security and the need to protect critical
aspects of the computer's behavior.Long before the internet, or even the emergence of networks,
designers managed how software components accessed system hardware and
MOTTAo1MUMMO3
carefully resources.
Processors were developed to support two operating modes: kernel mode and user mode.
Yao1oMHOBT
Kernel mode
Kernel mode refers to the processor mode that enables software to have full and unrestricted access to
the system and its resources.The OS kernel and kernel drivers, such as the file system driver, are loaded
into protected memory space and operate in this highly privileged kernel mode.
1ARBWO
User mode
(TOEYD010KHO9T
User mode refers to the processor mode that enables user-based applications, such as a word processor
or video game,to load and execute. The kernel prepares the memory space and resources for that
application's use and launches the application within that user memory space.
User mode applications are less privileged and cannot access system resources directly. Instead, an
application running in user mode must make system calls to the kernel to access system resources.The
kernel then acts as a manager, scheduler and gatekeeper for those
resources and works to prevent
conflicting resource requests.
The processorswitches tokernel mode as the kernel processesits system calls and then switches back
to user mode to continue operatingthe application(s).
It's worth noting that kernel and user modes are processor states and have nothing to do
with actual
solid-state memory. There is nothing intrinsically safe or protectedabout the memory used for kernel
mode. Kernel driver crashes and memory failures within the kernel memory space can still crash the OS
and the computer.
Types of kernels
Kernels fall into three architectures: monolithic, microkernel and The main
hybrid. difference between
these types is the numberof address spaces they support.
1. A microkernel delegates user processes and services and kernel services in different address spaces.
3. A hybrid kernel, such as the Microsoft Windows NT and Apple XNUkernels, attempts to combine the
behaviors and benefits of microkernel and monolithic kernel architectures.
Overall, these kernel implementations present a tradeoff -admins get the flexibility of more source
code with microkernels or they get increased security without customization options with the
monolithic kernel.
Some specific differencesamong the three kernel types include the following:
Microkernels
Microkernels have all of their services in the kernel address space. For their communication protocol,
microkernels use message passing, which sends data packets,signals and functions to the correct
processes. Microkernels also provide greater flexibility than monolithic kernels; to add a new service,
Because of their isolated nature, microkernels are more secure than monolithic kernels. They remain
unaffected if one servicewithin the address space fails.
883W0Y0010OHHORT0Ye
Monolithic kernels
Monolithic kernels are larger than microkernels, because they house both kernel and user services in the
same address space. Monolithic kernels use a faster system call communication protocol than
microkernels to execute processes between the hardware and software. They are less flexible than
microkernels and require more work; adminsmust reconstruct the entire kernel to support a new
service.
Monolithic kernels pose a greater security risk to systems than microkernelsbecause, if a service fails,
then the entire system shuts down. Monolithic kernels also don't require as much source code as a
microkernel,which means they are less susceptible to bugs and need less debugging.
The Linux kernel is a monolithic kernel that is constantly growing, it had 20 million lines of code in 2018.
From a foundational level, it is layered into a variety of subsystems. These main groups include a system
callinterface, process management, network stack, memory management, virtual file system and device
drivers.
Administrators can port the Linux kernel into their OSes and run live updates.These features, along with
the fact that Linux is open source, make it more suitable for server systems and environments that
require real-time maintenance.
Hybrid kernels
Apple developed the XNUOS kernel in 1996 as a hybrid of the Mach and Berkeley Software Distribution
(BSD) kernelsand paired it with an Objective-C application programming interface or API. Because it is a
combination of the monolithic kernel and microkernel,it has increased modularity, and parts of the OS
gain mermory protection.
User and kernel
physical memory
0010o00
o10n02
User Address Space
32 bit z2
G8
64i 8T8
10000o00
Kernet (System
Adoress Space
32 bit G8
2
64 bit8TB
See how user and kernel address space for physical memory is
configured in Windows 10.
Before the kernel, developers coded actions directly to the processor,insteadof relying on an OS to
complete interactions between hardware and software.
The first attempt to create an OS that used a kernel topass messages was in 1969with the RC 4000
Multiprogramming System. Programmer Per Brinch Hansen discovered it was easier to create a nucleus
and then build up an 0S,instead of converting existing OSes to be compatible with new hardware. This
nucleus --or kernel -contained all source code to facilitate communications and support systems,
eliminatingthe need to directly program on the CPU.
After RC 4000, Bell Labs researchers started work on Unix, which radically changed OS development and
kernel development and integration. The goalof Unix was to create smaller utilities that do specific
tasks well instead of having system utilities try to multitask. From a user standpoint, this simplifies
As Unix adoption increased, the market started to see a variety of Unix-like computer OSes, including
BSD, NeXTSTEP and Linux. Unix's structure perpetuated the idea that it was easier to build a kernel on
J3
top of an OS that reused software and had consistent hardware, instead of relying on a time-shared
system that didn't require an OS.
Unix brought OSes to more individual systems, but researchersat Carnegie Mellon expanded kernel
technology.From 1985 to 1994, they expanded work on the Mach kernel. Unlike BSD, the Mach kernel is
existing BSD software,enabling it to be available for immediate use and continued experimentation.
The Mach kernel's original goal was to be a cleanerversionof Unix and a more portableversion of
Carnegie Mellon's Accent interprocessorcommunications (IPC) kernel. Over time, the kernel brought
newfeatures, such as ports and IPC-based programs,and ultimately evolved into a microkernel.
Shortly after the Mach kernel, in 1986, Vrije Universiteit Amsterdam developer Andrew Tanenbaum
released MINIX (mini-Unix)for educational and research uses. This distribution contained a microkernel
based structure, multitasking, protected mode, extended memory support and an American National
The next major advancement in kernel technology came in 1992, with the release of the Linux kernel.
Founder Linus Torvalds developed it as a hobby, but he stilllicensed the kernel under general public
license,making it open source. It was first released with 176,250 lines of code.
The majorityof OSes -and their kernels - can be traced back to Unix, but there is one outlier: Windows.
With the popularityof DOS- and IBM-compatible PCs, Microsoftdeveloped the NT kernel and based its
OS on DOS. That is why writing commands for Windowsdiffers from Unix-based systerms.
32-Bit OS is required for running of 32-Bit Processors, as they are not capable of running on 64-bit
processors.
64-Bit Processors can run on any of the Operating Systems, like 32-Bit OS or 64-Bit OS.
Less amount of data is managed in 32-Bit Operating System as compared to 64-Bit Os.