0% found this document useful (0 votes)
11 views

OS Self - Notes

The document discusses the history and components of the UNIX operating system. It then covers different shells used in Linux including Bourne shell, C shell, Korn shell, bash, and zsh. The document also discusses shell variables, metacharacters, processes, and process states in an operating system.

Uploaded by

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

OS Self - Notes

The document discusses the history and components of the UNIX operating system. It then covers different shells used in Linux including Bourne shell, C shell, Korn shell, bash, and zsh. The document also discusses shell variables, metacharacters, processes, and process states in an operating system.

Uploaded by

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

An OS is a system software (i.e.

collection of system programs) which acts as an


interface
between user and hardware.

UNICS: UNICS – Uniplexed Information & Computing Services/System.


-first OS is UNICS
-developed by ken thompson,dennice Ritchie in 1970s at AT&T BELL labs
-first run on machine DEC-PDP-7 (Digital Equipment Corporation Programmable Data
Processing-7)
-UNICS is first ever MULTI-USER,MULTI-PROGRAMMING & MULTI-TASKING os.
-UNICS is mother of all modern os as there architecture design is based on it.

there are 2 major subsytems in UNICS:


process control subsystem
File Subsystem
In unics whaterver that can be stored is considered as file
and whatever is active is reffered as a process
- File has SPACE and process has LIFE
-in UNIX pov all files are considered to be file

===================================================================================
====

-------------SHELL PROGRAMMING------------------------------
WHAT IS SHELL??
SHELL is a program which provides the interface between the user and an operating
system.
A shell is a command-line interpreter program that parses and sends commands to the
operating system. This program represents an operating system's interactive
interface and the kernel's outermost layer (or shell). It allows users and programs
to send signals and expose an operating system's low-level utilities.

TYPES OF SHELL IN LINUX

1. Bourne Shell (sh)---->POARTABLE


It was written by Steve Bourne at AT&T Bell Labs. It is the original UNIX shell. It
is faster and more preferred. It lacks features for interactive use like the
ability to recall previous commands. It also lacks built-in arithmetic and logical
expression handling. It is default shell for Solaris OS.and the traditional
location is /bin/sh. The prompt switches to $, while the root prompt is #.

2. C Shell (csh)
Bill Joy created it at the University of California at Berkeley. It incorporated
features such as aliases and command history. It includes helpful programming
features like built-in arithmetic and C-like expression syntaxThe prompt switches
to %, while the root prompt is #.
The main drawbacks of the C shell are:
Syntax inconsistencies.
No support for standard input/output (stdio) file handles or functions.
Not fully recursive, which limits complex command handling

3. TENEX C Shell (tcsh)


The TENEX C shell (tcsh) is an extension of the C shell (csh) merged in the early
1980s. The shell is backward compatible with csh, with additional features and
concepts borrowed from the TENEX OS.
The TENEX C shell executable path is in /bin/tcsh. The user prompt is
hostname:directory> while the root prompt is hostname:directory#. Early versions of
Mac OS and the default root shell of FreeBSD use tcsh

4. KornShell (ksh)
It was written by David Korn at AT&T Bell Labs. It is a superset of the Bourne
shell. So it supports everything in the Bourne shell.It has interactive features.
It includes features like built-in arithmetic and C-like arrays, functions, and
string-manipulation facilities. It is faster than C shell. It is compatible with
script written for C shell.($ for a user and # for root)

5. Debian Almquist Shell (dash)


The Debian Almquist Shell (dash) is a Unix shell developed in the late 1990s from
the Almquist shell (ash), which was ported to Debian and renamed.
Dash is famous for being the default shell for Ubuntu and Debian. The shell is
minimal and POSIX compliant, making it convenient for OS startup scripts.
The executable path is /bin/dash, in addition to /bin/sh pointing to /bin/dash on
Ubuntu and Debian. The default and root user prompt is the same as in the Bourne
shell.

6. Bourne Again Shell (bash)--->POARTABLE


The Bourne Again Shell is a Unix shell and command language created as an extension
of the Bourne shell (sh) in 1989. The shell program is the default login shell for
many Linux distributions and earlier versions of macOS.
The shell name shortens to bash, and the location is /bin/bash. Like the Bourne
shell, the bash prompt is $ for a regular user and # for root

7. Z Shell (zsh)
The Z shell (zsh) is a Unix shell created as an extension for the Bourne shell in
the early 1990s. The feature-rich shell borrows ideas from ksh and tcsh to create a
well-built and usable alternative.
The executable location is in /bin/zsh. The prompt is user@hostname location % for
regular users and hostname# for the root user. The Z shell is the default shell of
Kali Linux and Mac OS

8. Friendly Interactive Shell (fish)


The Friendly Interactive Shell (fish) is a Unix shell released in the mid-2000s
with a focus on usability. The feature-rich shell does not require additional
configuration, which makes it user-friendly from the start.
The default executable path is /usr/bin/fish. The user prompt is user@hostname
location>, while the root prompt is root@hostname location#

----------------------------SHELL
VARIABLE--------------------------------------------

WILSCARD SYMBOLS

Asterisk (*) and question mark (?) are the two wildcard characters and ** to select
subdirectories

Both of these will match any character (including spaces, punctuation, and non-UTF
symbols). The asterisk matches any number of characters (including zero), and the
question mark matches exactly one character.

If you have a directory with files named myfile-1.txt, myfile-2.txt, and myfile-
3.txt, then you can match all three of these files with the wildcard expression
myfile-?.txt. This would exclude myfile-10.txt, though, as there is more than one
character in 10, so the single question mark wildcard would fail to match. If you
wanted both myfile-1.txt and myfile-10.txt to be matched, you would want to use
myfile-*.txt.

Matching subdirectories with **


You can match files in multiple subdirectories by including ** in the wildcard
match. For example, if you wanted to find all .txt files in all subdirectories of
the current directory, you could run ls **/*.txt. In some shells, this will only
search subdirectories, so you would have to combine it with *.txt if you also
wanted to include .txt files in the current directory. For the most part, though,
using **/*.txt will include all .txt files in the current directory as well as in
subdirectories

Use square brackets ([]) to match more specific characters

---------------------METACHARCHTER------------------------
Metacharacters: These are the special characters that are first interpreted by the
shell before passing the same to the command. They are also known as shell
wildcards.

$ Variable Substitution or expand the value of Variable.


> used for Output Redirection.
>> used for Output Redirection to append.
< Input redirection.
<< used for input redirection and is also known as here document.
* Match any number of characters, Substitution wildcard for zero or more
characters
? Match one character, Substitution wildcard for 1 character
[] Match range of characters, Substitution wildcard for any character
between brackets
`cmd` Replace cmd with the command to execute and will execute that,
Substitution wildcard for command execution
$(cmd) Replace cmd with the command to execute and will execute that,
Substitution wildcard for command execution
| Pipe is a Redirection to send the output of one command/program/process
to another command/program/process for further processing.
; Command separator is used to execute 2 or more commands with one
statement.
|| OR conditional execution of the commands.
&& AND conditional execution of the commands.
() Groups the command in to one output stream.
& executes command in the background and will display the assigned Pid.
# to comment something.
$ To expand the value of a variable.
\ used to escape the interpretation of a character or to prevent that.

The Escape Character or Backslash


A Backslash(‘\’) is the bash escape character. Any character immediately following
the backslash loses its special meaning and any letter following the backslash
gains its special meaning. Enter the following commands in the terminal.

---------------------------- PROCESSES
-----------------------------------------------
NON-PREEMPTIVE ---> we can not forcefully terminate this type of processes

PREEMPTIVE ---> Here we can pause existing process to execute other process

ORPHAN PROCESS & ZOMBIE PROCESS


Processes in OS bear parent-child relationship and they have their entry in the
system. An orphan process is formed when its parent dies while the process
continues to execute, while a zombie process is a process that has terminated but
its entry is there in the system

What happens with the zombie processes?


wait() system call is used for the removal of zombie processes.
wait() call ensures that the parent doesn't execute or sits idle till the child
process is completed.
When the child process completes executing, the parent process removes entries of
the child process from the process table. This is called "reaping of child".

MULTI-PROCESSING --->
There are two types of multiprocesses
1] ASSYMETRIC MULTI PROCESSES
Here os treats one of the process as master/special process and allows task to
it then that task gets divided into smaller task to get that process done from
other processor
2] SYMMETRIC MULTI PROCESSES
here all the processes are considered to be @ same level and hense os schedules
task to each processes individually
All modern system are SMP based

PROCESS STATE-->
NEW STATE
READY STATE
RUNNING STATE
WAITING STATE
TERMINATED STATE

To keep track of all running program os maintains few ds called as kernel ds


1. job Q --> queue of all submitted program
2. Ready Q --> queue of all the processes waiting for cpu time
3. waiting Q --> queue of all process who requsting for io from user

-----------------------------------------------------------------------------------
-------------------
PROCESS SCHEDULING
1] FCFS
2] SJF
3] RR
4] PRIORITY
-----------------------------------------------------------------------------------
What is paging?
Paging is a technique that eliminates the requirements of contiguous allocation of
main memory. In this, the main memory is divided into fixed-size blocks of physical
memory called frames. The size of a frame should be kept the same as that of a page
to maximize the main memory and avoid external fragmentation

What is Segmentation?
Segmentation is a technique that eliminates the requirements of contiguous
allocation of main memory. In this, the main memory is divided into variable-size
blocks of physical memory called segments. It is based on the way the programmer
follows to structure their programs. With segmented memory allocation, each job is
divided into several segments of different sizes, one for each module. Functions,
subroutines, stack, array, etc., are examples of such modules

You might also like