0% found this document useful (0 votes)
55 views39 pages

UNIX Operating System

The document discusses the history and features of UNIX and Windows operating systems. UNIX was developed in 1970 and is known for its multitasking, portability and security features. It has a hierarchical file structure and uses commands like cp and mv. Windows was first released in 1983 and various editions include Windows Home and Windows Professional. The document outlines the history of Windows versions from 1.0 to 11.

Uploaded by

minnasahi7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views39 pages

UNIX Operating System

The document discusses the history and features of UNIX and Windows operating systems. UNIX was developed in 1970 and is known for its multitasking, portability and security features. It has a hierarchical file structure and uses commands like cp and mv. Windows was first released in 1983 and various editions include Windows Home and Windows Professional. The document outlines the history of Windows versions from 1.0 to 11.

Uploaded by

minnasahi7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Aim: To understand types of Operating System and their difference.

UNIX operating system

UNIX is a powerful Operating System initially developed by Ken Thompson, Dennis Ritchie at
AT&T Bell laboratories in 1970. It is prevalent among scientific, engineering, and academic
institutions due to its most appreciative features like multitasking, flexibility, and many more. In
UNIX, the file system is a hierarchical structure of files and directories where users can store and
retrieve information using the files.

Features of UNIX Operating System:

 Multitasking: A UNIX operating system is a multitasking operating system that allows


you to initiate more than one task from the same terminal so that one task is performed as
a foreground and the other task as a background process.

 Multi-user: UNIX operating system supports more than one user to access computer
resources like main memory, hard disk, tape drives, etc. Multiple users can log on to the
system from different terminals and run different jobs that share the resources of a
command terminal. It deals with the principle of time-sharing. Time-sharing is done by a
scheduler that divides the CPU time into several segments also called a time slice, and

each segment is assigned to each user on a scheduled basis. This time slice is tiny. When
this time is expired, it passes control to the following user on the system. Each user
executes their set of instructions within their time slice.

 Portability: This feature makes the UNIX work on different machines and platforms
with the easy transfer of code to any computer system. Since a significant portion of
UNIX is written in C language, and only a tiny portion is coded in assembly language for
specific hardware.

 File Security and Protection: Being a multi-user system, UNIX makes special
consideration for file and system security. UNIX has different levels of security using
assigning username and password to individual users ensuring the authentication, at the
level providing file access permission viz. read, write and execute and lastly file
encryption to change the file into an unreadable format.

 Command Structure: UNIX commands are easy to understand and simple to use.
Example: "cp", mv etc. While working in the UNIX environment, the UNIX commands
are case-sensitive and are entered in lower case.

The structure of Unix OS Layers are as follows:


While working with UNIX OS, several layers of this system provide interaction between the pc
hardware and the user. Following is the description of each and every layer structure in UNIX
system:

Layer-1: Hardware -

This layer of UNIX consists of all hardware-related information in the UNIX environment.

Layer-2: Kernel -

The core of the operating system that's liable for maintaining the full functionality is named the
kernel. The kernel of UNIX runs on the particular machine hardware and interacts with the
hardware effectively.

It also works as a device manager and performs valuable functions for the processes which
require access to the peripheral devices connected to the computer. The kernel controls these
devices through device drivers.
The kernel also manages the memory. Processes are executed programs that have owner's
humans or systems who initiate their execution.

The system must provide all processes with access to an adequate amount of memory, and a few
processes require a lot of it. To make effective use of main memory and to allocate a sufficient
amount of memory to every process. It uses essential techniques like paging, swapping, and
virtual storage.

Layer-3: The Shell -

The Shell is an interpreter that interprets the command submitted by the user at the terminal, and
calls the program you simply want.

It also keeps a history of the list of the commands you have typed in. If you need to repeat a
command you typed it, use the cursor keys to scroll up and down the list or type history for a list
of previous commands. There are various commands like cat, mv, cat, grep, id, wc, and many
more.
Types of Shell in UNIX System:

o Bourne Shell: This Shell is simply called the Shell. It was the first Shell for UNIX OS. It
is still the most widely available Shell on a UNIX system.
o C Shell: The C shell is another popular shell commonly available on a UNIX system.
The C shell was developed by the University of California at Berkeley and removed some
of the shortcomings of the Bourne shell.
o Korn Shell: This Shell was created by David Korn to address the Bourne Shell's user-
interaction issues and to deal with the shortcomings of the C shell's scripting quirks.
What is Windows?

Windows is a graphical operating system developed by Microsoft. It allows users to view and
store files, run the software, play games, watch videos, and provides a way to connect to the
internet. It was released for both home computing and professional works.
Microsoft introduced the first version as 1.0

It was released for both home computing and professional functions of Windows on 10
November 1983. Later, it was released on many versions of Windows as well as the current
version, Windows 10.

Editions of Windows

Microsoft has produced several editions of Windows, starting with Windows XP. These versions
have the same core operating system, but some versions included advance features with an
additional cost. There are two most common editions of Windows:

o Windows Home
o Windows Professional

Windows Home

Windows Home is basic edition of Windows. It offers all the fundamental functions of Windows,
such as browsing the web, connecting to the Internet, playing video games, using office software,
watching videos. Furthermore, it is less expensive and comes pre-installed with many new
computers.

Windows Professional

Windows Professional is also known as Window Pro or win Pro. It is an enhanced edition of
Windows, which is beneficial for power users and small to medium-size businesses. It contains
all features of Windows Home as well as the following:

o Remote Desktop: Windows Professional editions allow users to create a remote desktop
connection. It provides users the option to connect with another computer remotely,
including share the control of its mouse, keyboard, and view display. It is mainly
accessed with the help of port 3389. Additionally, we can also use the TeamViewer or
VNC application to create a remote desktop connection.
o Trusted Boot: It provides security as encrypting to the boot loader and protects the
computer from rootkits (Collection of software tools that allow users to enter another
computer through an unauthorized way known as rootkits).
o Bitlocker: It allows users to encrypt a storage drive by using AES (Advanced Encryption
Standard) algorithm. This feature is present in Windows 7, and Windows Vista (Only
ultimate and Enterprise versions), including Windows Server 2008.
History of Microsoft Windows

Since 1983, Microsoft is producing Windows. The founder of Microsoft 'Bill Gates' announced
for Microsoft Windows on 10 November 1983 and released the first version
of Windows in 1985. The following table contains history of Windows from edition 1 to 10.

The history of Microsoft Windows is a timeline of evolution and innovation in the world of personal computing:

1. Windows 1.0 (1985): Microsoft introduced its first graphical user interface (GUI) with Windows 1.0. It featured
overlapping windows, a taskbar, and the iconic MS-DOS Executive.

2. Windows 2.0 (1987): Windows 2.0 improved graphics and allowed for better multitasking and the ability to
minimize and maximize windows.

3. Windows 3.0 (1990): Windows 3.0 was a significant milestone, offering improved performance, a revamped user
interface, and compatibility with a broader range of software. It became a commercial success.

4. Windows 3.1 (1992): Windows 3.1 brought further enhancements, including TrueType fonts and multimedia
support, making it even more popular

5. Windows 95 (1995): Windows 95 was a major release, featuring the Start menu, taskbar, and Plug and Play
support. It was a significant step toward modern Windows interfaces.

6. Windows 98 (1998): Windows 98 improved stability and added features like the Windows Driver Model (WDM)
and Internet Explorer integration.

7. Windows Me (Millennium Edition) (2000): Windows Me targeted home users with multimedia enhancements but
faced criticism for its stability issues.

8. Windows 2000 (2000): Windows 2000 was a business-oriented release, built on a more stable foundation than its
predecessors, incorporating the NT kernel.

9. Windows XP (2001): Windows XP combined the stability of Windows 2000 with a user-friendly interface. It
became one of the most beloved and enduring Windows versions.

10. Windows Vista (2007): Windows Vista introduced improved security features, but it faced criticism for its high
system requirements and performance issues.

11. Windows 7 (2009): Windows 7 addressed many of the issues with Vista, providing a more stable and efficient
operating system.

12. Windows 8 (2012): Windows 8 introduced a touch-oriented interface and was designed to work across a variety
of devices, including tablets and PCs.

13. Windows 8.1 (2013): Windows 8.1 refined the Windows 8 experience with updates and the return of the Start
button.

14.Windows 10 (2015): Windows 10 brought back the Start menu, integrated Cortana (voice assistant), and
introduced a continuous update model, ensuring users had access to the latest features and security patches.

15. Windows 11 (2021): Windows 11 represents the latest major release as of my last knowledge update in
September 2021. It features a redesigned Start menu, enhanced gaming capabilities, and improvements in
productivity and security
Features of windows
1. Graphical User Interface (GUI): Windows is known for its user-friendly GUI, which includes features
like a Start menu, taskbar, and windowed applications. This graphical interface makes it easy for users to
interact with the system.
2.Software Compatibility: Windows has an extensive library of software applications, making it a
versatile platform for various tasks, from productivity and gaming to business applications. Many popular
software titles are developed for Windows.
3. Security Features: Windows includes built-in security features such as User Account Control (UAC),
Windows Defender antivirus, and a firewall to protect against security threats, malware, and unauthorized
access.
4. Networking Capabilities: Windows provides comprehensive networking support, allowing users to
connect to various networks, share resources, and access the internet seamlessly. It also supports features
like Home Group for easy file and printer sharing in home networks.
5. Regular Updates: Microsoft regularly releases updates and security patches to keep Windows systems
secure and up-to-date with the latest features and improvements. This helps ensure the stability and
security of the operating system.

Windows Architecture
In the image above we can see the HAL (Hardware Abstraction Layer), which is the first
abstraction layer that abstracts the hardware details from the operating system. The operating
system can then call the same API functions and the HAL takes care of how they are actually
executed on the underlying hardware. Every driver that is loaded in the kernel mode uses HAL to
interact with the hardware components, so even the drivers don’t interact with hardware directly.
The kernel drivers can interact with the hardware directly, but usually they don’t need to, since
they can use HAL API to execute some action. The hardware abstraction layer’s API is provided
with the hal.dll library file that is located in the C:\WINDOWS\system32\ directory as can be
seen below:

The rest of the system kernel components are provided by the following libraries and
executables:

 exe : manages user processes and threads


 sys : user and graphics device driver (GDI)
 dll : access to resources like file system, devices, processes, threads and error handling in
Windows systems
 dll : access to windows registry, shutdown/restart the system, start/stop/create services,
manage user accounts
 dll : create and manage screen windows, buttons, scrollbars, receive mouse and keyboard
input
 dll : outputs graphical content to monitors, printers and other output devices
 dll : dialog boxes for opening and saving files, choosing color and font
 dll : access to status bars, progress bars, tools, tabs
 dll : access the operating system shell
 dll : access to networking functions

The programs can use Windows API (Win 32 API) to implement the needed actions. But the
WinAPI uses the described DLL libraries underneath. Right above the kernel mode is the user
mode, where the most important library is ntdll.dll. That can be used as an entry point into the
kernel if some process needs services of the kernel.

Introduction to Linux Operating System


Linux is a community of open-source Unix like operating systems that are based on the Linux
Kernel. It was initially released by Linus Torvalds on September 17, 1991. It is a free and
open-source operating system and the source code can be modified and distributed to anyone
commercially or noncommercially under the GNU General Public License.
Initially, Linux was created for personal computers and gradually it was used in other
machines like servers, mainframe computers, supercomputers, etc. Nowadays, Linux is also
used in embedded systems like routers, automation controls, televisions, digital video
recorders, video game consoles, smartwatches, etc. The biggest success of Linux is
Android(operating system) it is based on the Linux kernel that is running on smartphones and
tablets. Due to android Linux has the largest installed base of all general-purpose operating
systems. Linux is generally packaged in a Linux distribution.

Linux Distribution

Linux distribution is an operating system that is made up of a collection of software based on


Linux kernel or you can say distribution contains the Linux kernel and supporting libraries and
software. And you can get Linux based operating system by downloading one of the Linux
distributions and these distributions are available for different types of devices like embedded
devices, personal computers, etc. Around 600 + Linux Distributions are available and some of
the popular Linux distributions are:
 MX Linux
 Manjaro
 Linux Mint
 elementary
 Ubuntu
 Debian
 Solus
 Fedora
 openSUSE
 Deepin
Architecture of Linux

Linux architecture has the following components:

1. Kernel: Kernel is the core of the Linux based operating system. It virtualizes the common
hardware resources of the computer to provide each process with its virtual resources. This
makes the process seem as if it is the sole process running on the machine. The kernel is
also responsible for preventing and mitigating conflicts between different processes.
Different types of the kernel are:
 Monolithic Kernel
 Hybrid kernels
 Exo kernels
 Micro kernels
2. System Library: Isthe special types of functions that are used to implement the
functionality of the operating system.
3. Shell: It is an interface to the kernel which hides the complexity of the kernel’s functions
from the users. It takes commands from the user and executes the kernel’s functions.
4. Hardware Layer: This layer consists all peripheral devices like RAM/ HDD/ CPU etc.
5. System Utility: It provides the functionalities of an operating system to the user.
Advantages of Linux

 The main advantage of Linux, is it is an open-source operating system. This means the
source code is easily available for everyone and you are allowed to contribute, modify and
distribute the code to anyone without any permissions.
 In terms of security, Linux is more secure than any other operating system. It does not
mean that Linux is 100 percent secure it has some malware for it but is less vulnerable than
any other operating system. So, it does not require any anti-virus software.
 The software updates in Linux are easy and frequent.
 Various Linux distributions are available so that you can use them according to your
requirements or according to your taste.
 Linux is freely available to use on the internet.
 It has large community support.

Disadvantages of Linux

 It is not very user-friendly. So, it may be confusing for beginners.


 It has small peripheral hardware drivers as compared to windows.

Linux File System Structure

Linux file system has a hierarchal file structure as it contains a root directory and its
subdirectories. All other directories can be accessed from the root directory. A partition usually
has only one file system, but it may have more than one file system.

A file system is designed in a way so that it can manage and provide space for non-volatile
storage data. All file systems required a namespace that is a naming and organizational
methodology. The namespace defines the naming process, length of the file name, or a subset of
characters that can be used for the file name. It also defines the logical structure of files on a
memory segment, such as the use of directories for organizing the specific files. Once a
namespace is described, a Metadata description must be defined for that particular file.

The data structure needs to support a hierarchical directory structure; this structure is used to
describe the available and used disk space for a particular block. It also has the other details
about the files such as file size, date & time of creation, update, and last modified.

Also, it stores advanced information about the section of the disk, such as partitions and
volumes.

The advanced data and the structures that it represents contain the information about the file
system stored on the drive; it is distinct and independent of the file system metadata.
Linux file system contains two-part file system software implementation architecture. Consider
the below image:

The file system requires an API (Application programming interface) to access the function calls
to interact with file system components like files and directories. API facilitates tasks such as
creating, deleting, and copying the files. It facilitates an algorithm that defines the arrangement
of files on a file system.

The first two parts of the given file system together called a Linux virtual file system. It
provides a single set of commands for the kernel and developers to access the file system. This
virtual file system requires the specific system driver to give an interface to the file system.
Difference between Windows, Unix and Linux

Aspect Windows Unix Linux

Operating
System Type Proprietary Open Source (Unix-like) Open Source (Unix-like)

Kernel Windows NT kernel Various Unix kernels Linux kernel

Command Line Interface (CLI) Command Line Interface (CLI)


and optional graphical and optional graphical
Graphical interfaces (e.g., X Window interfaces (e.g., GNOME,
User Interface (Windows GUI) System) KDE)

NTFS, FAT32,
File System exFAT, ReFS Various (e.g., ext4, ZFS, UFS) Various (e.g., ext4, XFS, Btrfs)

Command Prompt
(cmd.exe),
Shell PowerShell Various (e.g., Bash, Zsh, tcsh) Various (e.g., Bash, Zsh)

Access Control
User Lists (ACLs) and User and group-based User and group-based
Permissions user groups permissions permissions

Q2. To understand help commands like:- man, info, help, whatis, apropos
man Command
Syntax
$man [OPTION]... [COMMAND NAME]...
Description
man command in Linux is used to display the user manual of any command that we can run on
the terminal. It provides a detailed view of the command which includes NAME, SYNOPSIS,
DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES,
VERSIONS,

info Command
Syntax:
info [OPTION]... [MENU-ITEM...]
Description
info command reads documentation in the info format. It will give detailed information for a
command when compared with the man page. The pages are made using the texinfo tools
because of which it can link with other pages, create menus and easy navigation.
help Command
Syntax:
help [OPTION]...
Options for help command
 -d option : It is used when you just want to get an overview about any shell built-in
command i.e it only gives short description.
 -m option : It displays usage in pseudo-manpage format.
 -s option : It just displays only a short usage synopsis for each topic matching.
Description
The help command provides information on built-in commands. Built-in commands are any
programs bundled with your version of the bash shell. For a complete list of the built-in
commands available to you, simply enter 'help' at the terminal prompt.
whatis command
Syntax:
whatis [-options]
Description
whatis command in Linux is used to get a one-line manual page description. In Linux, each
manual page has some sort of description within it. So, this command search for the manual
pages names and show the manual page description of the specified filename or argument.

Apropos Command
Syntax
apropos [OPTIONS] keyword ...
Description
In computing, apropos is a command to search the man page files in Unix and Unix-like
operating systems. Apropos takes its name from the French "à propos" (Latin "ad prōpositum")
which means about. It is particularly useful when searching for commands without knowing their
exact names.
AIM: To study various commands to perform operations on file.

1. cat: create file, display contents, append file and concatenate two files.
SYNTAX:
$ cat [OPTION] [FILE NAME].
DESCRIPTION:
cat is one of the most common commands in Linux. It is mainly used to

∙ Copy text files.


∙ Combine text files.
∙ Create new text files
∙ Display text files on screen
∙ Append those files

Ctrl+d to exit after adding contents.

OPTIONS:
cat > filename: This command is used to create files in current directory and would allow
adding contents to it (after pressing ‘enter’).
cat filename: This command is used to display content of files.
cat filename1 filename2 destination filename: concatenate file1 & file2 and add to destination
file.
cat>>filename: append the contents.
OUTPUT:
2. rm: Delete file.
SYNTAX:
$ rm [OPTION] [FILE NAME1 FILENAME2].
DESCRIPTION:
Delete a file or more than one files. rm* deletes all files of directory. Once deleted filed file can
never be restored.
OPTIONS:
-i: interactive deletion of file i.e. prompts for asking whether to delete file or not.
-r: recursive deletion i.e. deletes all directory, sub-directory and name of current directory.
OUTPUT:

3. cp: copy file


SYNTAX:
$ cp filename1 …..filename n
DESCRIPTION:
This command is used to copies a file or group of files to another file. It simply creates an
image of the file with different name.
OPTIONS:
cp file1 file2: It copies file1 into file2.
cp file1 dir1: create a copy in directory dir1 with file name file.
-i: interactive copy
-r: recursive copy
OUTPUT:

4. mv: rename a file or directory.


SYNTAX:
$ mv [OPTION]... OLDNAME NEWNAME

DESCRIPTION:
This command is used to rename or move a file. This command can also be a user to move a
file from one directory to another. It does not create copy of the file, it merely renames it.
OPTIONS:
mv oldfile newfile: It is used for moving the contents of oldfile name to newfile name. mv
file1 flie2 dir1: move file1 and file2 to the directory dir1.

OUTPUT:
5.mkdir : make a directory
Syntax
mkdir [options...] [directories ...]
Options
-m : set file mode (as in chmod), not a=rwx - umask
-p, --parents : no error if existing, make parent directories as needed,
with their file modes unaffected by any -m option.
-v, --verbose : print a message for each created directory

Description
mkdir command in Linux allows the user to create directories (also referred to as folders in some
operating systems). This command can create multiple directories at once as well as set the
permissions for the directories.

Output

6.rmdir: remove a file or directory


Syntax
rmdir [options..] [directories..]
Options
--ignore-fail-on-non-empty : ignore each failure that is solely because a directory is non-empty
-p, --parents : remove DIRECTORY and its ancestors; e.g., 'rmdir -p a/b/c is similar to
'rmdir a/b/c a/b a'
-v, --verbose: output a diagnostic for every directory processed
Description
rmdir command in Linux allows the user to delete directories (also referred to as folders in some
operating systems). This command can delete multiple directories at once.

Output:

7.cd: change directory


Syntax
cd directory
Description
The cd command is a common command used in the Linux terminal, including Kali Linux. It
stands for "change directory" and is used to change your current working directory within the
file system. This command is essential for navigating through the directory structure on your
system.

Output:

8.pwd: display present working directory.


Syntax
pwd
Description
The pwd command in Kali Linux, as well as in other Linux distributions, stands for "Print
Working Directory." When you run the pwd command, it displays the absolute path of the
current working directory in the terminal.

Output:

Aim: To understand basic commands like: date, cal, echo, bc, ls, who, whoami, hostname, uname, tty,
aliase
date command

Syntax
date [OPTION]... [+FORMAT]
Options
-r, --reference=FILE : display the last modification time of FILE
-s, --set=STRING : set time described by STRING
-u, --utc, --universal : print or set Coordinated Universal Time (UTC)
Description
The date command in Kali Linux, as in most Unix-like operating systems, is used to display or
manipulate the system date and time. It can also be used to set the system date and time.

Cal command

Syntax
cal [options] [month] [year]
Options
-1: Display the calendar in a single column, showing only the current month.
-3: Display the calendar for the previous, current, and next months in a horizontal layout.
-y: Display a calendar for the entire year, showing all months in a grid.
Description
The cal command in Kali Linux, as in other Linux distributions, is used to display a simple
calendar for the current month or any specified month and year.
Echo command

Syntax
echo [Option] “String..”
Options
-n: Suppresses the trailing newline character.
-e: Enables interpretation of backslash escapes (e.g., \n for a newline character).
-E: Disables the interpretation of backslash escapes (default behavior).
Description
In Kali Linux and other Linux distributions, the echo command is a built-in shell command that is used to
display text or messages on the terminal.

Bc command

Syntax
bc
or
bc < filename(having mathematical eqn)
Description
The bc command in Kali Linux, like in other Linux distributions, is a command-line calculator tool that
allows you to perform mathematical calculations. "bc" stands for "basic calculator."
Ls command

Syntax
ls [Option]
Options
-l (long format): Displays detailed information about the files and directories, including
permissions, owner, group, size, and modification time.
-a (all files): Lists all files, including hidden files (files whose names start with a dot .).
-t (sort by time): Sorts the files and directories by modification time in descending order (most
recent first).
-r (reverse order): Reverses the order of sorting, so files and directories are listed in reverse
order.
Description
The ls command is a common command in Unix-like operating systems, including Kali Linux, that is
used for listing the files and directories in a given directory.

Who command

Syntax
who [OPTION]... [FILE]...
Options
-H: Display column headers.
-a: Show all information (equivalent to who -b -d --login -p -r -t -T -u).
-b: Show the time of the last system boot.
-d: Display dead processes as well.
-l: Display only the login names and the terminal names (omits other information).
Description
Whoami command

Syntax
Options
Description
The who command in Kali Linux (and other Linux distributions) is used to display information about the
users who are currently logged into the system. It provides details about each logged-in user, including
their username, terminal, login time, and more.

Hostname command

Syntax
hostname [OPTION]...
Options
-s option will display the short hostname.
-f option will display the Fully Qualified Domain Name (FQDN) of the system, including the
hostname and the DNS domain.
-d option will display the DNS domain name of the system.
Description
The hostname command in Kali Linux is used to display or set the system's hostname.

Uname command

Syntax
Uname [Option]
Options
-s: To display the system's kernel name, use the -s option.
-n: This option shows the network node hostname, which is often the same as the computer's
hostname.
-r: The -r option displays the kernel release version.
-v: Use the -v option to display the kernel version.
Description
The uname command in Kali Linux, as in most Linux distributions, is used to display system
information about the operating system.

Tty command

Syntax
tty
Description
The tty command in Kali Linux, as well as in many other Unix-like operating systems, is used to print the
file name of the terminal connected to the standard input

aliase command

Syntax
alias alias_name='command_to_alias'
Description
In Kali Linux, as in many Linux distributions, you can use aliases to create shortcuts for longer
commands. Aliases are defined in your shell's configuration files (e.g., ~/.bashrc, ~/.zshrc, etc.),
and they make it easier to execute commonly used or complex commands.
Aim: To understand vi basics, Three modes of vi Editor, how to write, save, execute a shell
script in vi editor.
Vi text editor is essential for creating and editing text, including shell scripts. Vi operates in three
primary modes: Normal mode, Insert mode, and Command-Line mode. Here's how to navigate
these modes and create, save, and execute a shell script in Vi:
1. Normal Mode:
• This is the default mode when you open a file in Vi.
• In Normal mode, you can navigate the document and perform various text
manipulation tasks.
2. Insert Mode:
• To enter Insert mode, press i in Normal mode. This allows you to edit and
input text.
• Press Esc to return to Normal mode from Insert mode.
3. Command-Line Mode:
• To enter Command-Line mode, press : in Normal mode. This mode is used for
executing commands and saving the file.
• To save changes, use :w. For example, :w filename to save as "filename."
• To save and exit, use :wq or :x.
• To exit without saving, use :q!.
Here's how you can create, save, and execute a shell script using Vi:
1. Create a Shell Script:
• Open a terminal and enter vi script.sh (or any filename you prefer).
• You'll start in Normal mode. Press i to enter Insert mode.
• Write your shell script in Insert mode.
• When you finish writing the script, press Esc to return to Normal mode.
2. Save the Shell Script:
• In normal mode, press shift+zz to save the changes
• Press Enter to save the file.
3. Execute the Shell Script:
• To execute the shell script, open your terminal.
• Navigate to the directory where the script is located using the cd command.
• Make the script executable using chmod +x script.sh.
• Run the script with ./script.sh or bash filename.

Example,
Aim:-Write a program to find the greater of two numbers.
Aim: - Write a program to find the greatest of three numbers.
EXPERIMENT NO: 12

Aim:- Write a program to determine whether a number is prime or not.


EXPERIMENT NO: 13

Aim: - Write a program to determine whether a string is palindrome or not.


EXPERIMENT NO: 14

Aim: - Write a program to find the Fibonacci series.


EXPERIMENT NO: 10

Aim: - Write a program to find whether a number is even or odd.


EXPERIMENT NO: 11

Aim: - Write a program to find the factorial of a given number.

You might also like