Unit 1 Part 2 Operating System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

Overview of UNIX

 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.
 Communication: In UNIX, communication is an excellent feature
that enables the user to communicate worldwide. It supports various
communication facilities provided using the write command, mail
command, talk command, etc.
 Open Source: UNIX operating system is open source it means it is
freely available to all and is a community-based development project.
 Accounting: UNIX keeps an account of jobs created by the
user. This feature enhances the system performance in
terms of CPU monitoring and disk space checking. It
allows you to keep an account of disk space used by each
user, and the disk space can be limited by each other. You
can assign every user a different disk quota. The root user
can perform these accounting tasks using various
commands such as quota, df, du, etc.
 UNIX Tools and Utilities: UNIX system provides various
types of tools and utilities facilities such as UNIX grep, sed
and awk, etc. Some of the general-purpose tools are
compilers, interpreters, network applications, etc. It also
includes various server programs which provide remote
and administration services.
The structure of Unix OS
 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:
 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.
 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.
 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.
 Layer-4: Application Programs Layer -
 It is the outermost layer that executes the given
external applications. UNIX distributions typically
come with several useful applications programs as
standard. For Example: emacs editor, StarOffice, xv
image viewer, g++ compiler etc.
Overview of Linux Operating
System

 Linux is an open-source Unix-like operating system-based


family on the Linux kernel, and the OS kernel was first
published on 17 September 1991 by Linus Torvalds.
Typically, Linux is packaged as the Linux distribution,
which contains the supporting libraries and system
software and kernel, several of which are offered by the
GNU Project.
 Linux is one of popular version of UNIX operating System.
It is open source as its source code is freely available. It is
free to use. Linux was designed considering UNIX
compatibility. Its functionality list is quite similar to that of
UNIX.
Components of Linux System

 Linux Operating System has primarily three components


 Kernel − Kernel is the core part of Linux. It is responsible for all
major activities of this operating system. It consists of various
modules and it interacts directly with the underlying hardware.
Kernel provides the required abstraction to hide low level
hardware details to system or application programs.
 System Library − System libraries are special functions or
programs using which application programs or system utilities
accesses Kernel's features. These libraries implement most of the
functionalities of the operating system and do not requires
kernel module's code access rights.
 System Utility − System Utility programs are responsible to do
specialized, individual level tasks.
Basic Features
 Following are some of the important features of Linux Operating System.
 Portable − Portability means software can works on different types of hardware in same
way. Linux kernel and application programs supports their installation on any kind of
hardware platform.
 Open Source − Linux source code is freely available and it is community based
development project. Multiple teams work in collaboration to enhance the capability of
Linux operating system and it is continuously evolving.
 Multi-User − Linux is a multiuser system means multiple users can access system
resources like memory/ ram/ application programs at same time.
 Multiprogramming − Linux is a multiprogramming system means multiple
applications can run at same time.
 Hierarchical File System − Linux provides a standard file structure in which system
files/ user files are arranged.
 Shell − Linux provides a special interpreter program which can be used to execute
commands of the operating system. It can be used to do various types of operations, call
application programs. etc.
 Security − Linux provides user security using authentication features like password
protection/ controlled access to specific files/ encryption of data.

Architecture
 The architecture of a Linux System consists of the following
layers −
 Hardware layer − Hardware consists of all peripheral
devices (RAM/ HDD/ CPU etc).
 Kernel − It is the core component of Operating System,
interacts directly with hardware, provides low level services
to upper layer components.
 Shell − An interface to kernel, hiding complexity of
kernel's functions from users. The shell takes commands
from the user and executes kernel's functions.
 Utilities − Utility programs that provide the user most of
the functionalities of an operating systems.
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.
 It provides high stability. It rarely slows down or freezes and there is no need to reboot it after a short time.
 It maintain the privacy of the user.
 The performance of the Linux system is much higher than other operating systems. It allows a large number of people
to work at the same time and it handles them efficiently.
 It is network friendly.
 The flexibility of Linux is high. There is no need to install a complete Linux suit; you are allowed to install only
required components.
 Linux is compatible with a large number of file formats.
 It is fast and easy to install from the web. It can also install on any hardware even on your old computer system.
 It performs all tasks properly even if it has limited space on the hard disk.
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.
Difference between Unix and
Linux
Linux Unix

The source code of Linux is freely The source code of Unix is not freely
available to its users available general public

It has graphical user interface along


It only has command line interface
with command line interface

Linux OS is portable, flexible, and can


Unix OS is not portable
be executed in different hard drives

Different versions of Linux OS are


Different version of Unix are AIS, HP-
Ubuntu, Linux Mint, RedHat
UX, BSD, Iris, etc.
Enterprise Linux, Solaris, etc.

The file systems supported by Linux are


as follows: xfs, ramfs, vfat, cramfsm, The file systems supported by Unix are
Linux Unix
inux is an open-source operating system that was first Unix is a proprietary operating system that was originally
released in 1991 by Linus Torvalds. developed by AT&T Bell Labs in the mid 1960s.

User Interface of Linux is Graphical or text-based. User Interface of unix is text-based.

Unix was originally designed to run on large, expensive


Linux has much broader hardware support than Unix. mainframe computers, while Linux was designed to run
on commodity hardware like PCs and servers.
Linux Unix
Command Line Interface of Linux is Bash, Zsh, Tcsh. Command Line Interface of unix is Bourne, Korn, C, Zsh.

The Unix kernel is modular, meaning that it is made up


The Linux kernel is monolithic, meaning that all of its
of a collection of independent modules that can be
services are provided by a single kernel.
loaded and unloaded dynamically.
Understanding of
common commands
man Commands
 man command in Linux is used to display the user
manual of any command that we can run on the
terminal
date
 date command is used to display the system date and
time. date command is also used to set date and time
of the system. By default the date command displays
the date in the time zone on which unix/linux
operating system is configured.
 Options with Examples
 1: date (no option): With no options, the date
command displays the current date and time,
including the abbreviated day name, abbreviated
month name, day of the month, the time separated by
colons, the time zone name, and the year.

 2: -u Option: Displays the time in GMT(Greenwich


Mean Time)/UTC(Coordinated Universal Time )time
zone.
 3: –date or -d Option: Displays the given date string
in the format of date. But this will not affect the
system’s actual date and time value.

 https://www.geeksforgeeks.org/date-command-linux-
examples/
whoami
 whoami command is used both in Unix Operating
System and as well as in Windows Operating System.
 It is basically the concatenation of the
strings “who”,”am”,”i” as whoami.
 It displays the username of the current user when this
command is invoked.
 It is similar as running the id command with the
options -un.
 Whoami –version


who
 Report which users are logged in to the system.
w
 Show who is logged on and what they are doing.
cal
 the cal command shows the current month calendar as
output.
 cal command is a calendar command in Linux which
is used to see the calendar of a specific month or a
whole year.
 Cal –y
cal 02 2021 : Shows calendar of selected month and year.

cal 2021 | more : But year may not be visible in the same screen use more with
cal use spacebar to scroll down.

https://www.geeksforgeeks.org/cal-command-in-linux-with-examples/
bc
 bc command is used for
command line
calculator. It is similar
to basic calculator by
using which we can do
basic mathematical
calculations.
Arithmetic operations
are the most basic in
any kind of
programming language.
 There are two main ways in which the bc command
works. The first is through entering an interactive
mathematical shell. We can enter the shell by simply
running the bc command by itself.
 Once we’re in, we can start executing some basic
mathematical operations.
 But we can also perform mathematical operations in
the Linux terminal using bc without entering the
interactive shell. For this process, we’ll need to utilize
the echo command and | pipes. This will echo any text
we type and pass it to the bc command.
 We can also use bc to compute numerous
mathematical operations that are contained in a text
file. Simply pass a text file filled with math equations
to the bc command and let it do its job.
hostname
 Linux hostname command allows us to set and view
the hostname of the system. A hostname is the name
of any computer that is connected to a network that is
uniquely identified over a network. It can be accessed
without using a particular IP address.
 https://www.geeksforgeeks.org/hostname-command-
in-linux-with-examples/
uname
The command ‘uname‘ displays the information about the system.
basic directory navigation
commands
cd
 Linux cd command is used to change the current
working directory ( i.e., in which the current user is
working). The "cd" stands for 'change directory.' It is
one of the most frequently used commands in the
Linux terminal.
mv
 Linux mv command is used to move existing file or
directory from one location to another. It is also used
to rename a file or directory.
Renaming a file in Linux
copy
 cp stands for a copy. This command is used to copy
files or groups of files or directories. It creates an exact
image of a file on a disk with a different file
name. cp command requires at least two filenames in
its arguments.
 https://www.geeksforgeeks.org/cp-command-linux-
examples/
 If the command contains two file names, then it
copies the contents of 1st file to the 2nd file. If the
2nd file doesn’t exist, then first it creates one, and
content is copied to it. But if it existed then it is simply
overwritten without any warning. So be careful when
you choose the destination file name.
Copy more than one file into directory
rm
 The 'rm' means remove. This command is used to
remove a file.
 No output is produced by rm, since it typically only
generates messages in the case of an error.
 -i (Interactive Deletion): the -i option makes the
command ask the user for confirmation before
removing each file, you have to press y for confirm
deletion, any other key leaves the file un-deleted.
 -f (Force Deletion): rm prompts for confirmation
removal if a file is write protected. The -f option
overrides this minor protection and removes the file
forcefully.
cat
 Cat is short for concatenate. This command displays
the contents of one or more files without having to
open the file for editing.
 Cat(concatenate) command is very frequently used in
Linux. It reads data from the file and gives its content
as output. It helps us to create, view, and concatenate
files.
 1) To view a single file
 2) To view multiple files

 To view contents of a file preceding with line
numbers.
Vi Editor
 The vi editor is elaborated as visual editor. It is
installed in every Unix system. In other words, it is
available in all Linux distros. It is user-friendly and
works same on different distros and platforms. It is a
very powerful application.
 The vi editor has two modes:
 Command Mode: In command mode, actions are taken on the
file. The vi editor starts in command mode. Here, the typed
words will act as commands in vi editor. To pass a command, you
need to be in command mode.
 Insert Mode: In insert mode, entered text will be inserted into
the file. The Esc key will take you to the command mode from
insert mode.
 By default, the vi editor starts in command mode. To enter text,
you have to be in insert mode, just type 'i' and you'll be in insert
mode. Although, after typing i nothing will appear on the screen
but you'll be in insert mode. Now you can type anything.
 To exit from insert mode press Esc key, you'll be directed to
command mode.
 The vi editor tool is an interactive tool as it displays
changes made in the file on the screen while you edit
the file.
 In vi editor you can insert, edit or remove a word as
cursor moves throughout the file.
 The vi editor is case-sensitive.

You might also like