Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Title: Unix Operating System
Description: This PDF contains full explanation of Unix Operating System. This PDF had theory as well as shell scripts which can be very useful and for understanding Unix OS
Description: This PDF contains full explanation of Unix Operating System. This PDF had theory as well as shell scripts which can be very useful and for understanding Unix OS
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
Theory
http://www
...
com/virtim/index
...
The UNIX operating system originated in the AT & T Bell laboratory and university of California
...
In the later 1969, Dennis Ritchie and Ken Thompson developed one operating system called UNICS
[Uniplexed Information & Computing Service]
...
Later Ken Thompson added some features with this operating system and rewrote the operating system using a
high level language but it also didn't satisfy all the features
...
Features Of Unix
It is a powerful operating system and it offers several features
...
Multi-user Capability
...
Multi-tasking capability
...
Security
4
...
Communication
Multi-user Capability
...
It supports multiple users at a time
...
The main concept is that the main computer is connected to the number of terminals
which consists of only keyboard, mouse and monitor
...
This proves Multi-user capability
...
In UNIX operating system more than one job can be performed at the same time
...
The only difference between multi-user and multi-tasking systems
is that in multi-user system, different tasks of different user are being performed where as in multi-tasking, different tasks
belonging to one user are running concurrently
...
So, authentication and confidentiality for user information is
required
...
This also provides one
type of security to the user
...
Portability
The UNIX operating system is very suitable for any type of environment
...
It can easily be implemented on different hardware platforms with little or no modifications
...
Communication can be established between users working in different terminals
...
The users can easily exchange the mail, data, programs,
etc using that network
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
The innermost layer is the hardware layer
...
The three major layers are:
1
...
Kernel mode
3
...
User mode
On the application programs and some other softwares are present in this layer
...
2
...
The kernel has various functions
...
The Kernel program of UNIX is usually stored in a file
called unix
...
Hardware
Different types of hardware which are connected with a UNIX system, they can drive by the Kernel
...
Kernel
ii
...
File System
...
Kernel
It is the main part of operating system which is an interface between hardware and the shell
...
ii
...
The shell acts as a command
interpreter which interprets the command and transfers them to the kernel for execution
...
File System
In UNIX everything including hardware device is treated as a file
...
UNIX file system could be local or distributed
...
Whenever distributed file system allow the file access on remote machine
...
There are mainly three types of shell that are present in UNIX
...
Bourne shell (sh)
2
...
Korn shell (ksh)
2 of 15
2/1/2016 9:04 AM
Theory
http://www
...
com/virtim/index
...
Note: Bash shell Bourne + Korn
1
...
This shell is present in every UNIX operating system
...
2
...
It has two advantages over the Bourne shell
...
It allows aliasing of commands i
...
the user can decide the name
...
Instead of typing the entire command, you can simply use the short alias name
...
The default prompt of C shell is
“%"
...
Korn Shell
It was created by David Korn at AT & T Bell laboratory
...
It is widely used for any types of
commands to execute because it is very powerful
...
Bash: This is another type of shell which added some extra features of Bourne shell
...
Write a short note on UNIX file system
...
The file maybe a program, file, a directory or a
sub-directory
...
The UNIX file system begins with a directory called root
...
Branching from the root there are several other directories called bin, lib, usr, etc,
tmp, dev and unix
...
Each of these
sub-directories contains several files as well as other directories (sub-sub-directory)
...
The following table describes all these sub-directories
3 of 15
Directory
Contains
unix
UNIX kernel is present in this directory
bin
Binary executable file
lib
Library function
dev
Device related files
2/1/2016 9:04 AM
Theory
http://www
...
com/virtim/index
...
etc
Binary executable file usually required for system
tmp
Temporary files created by unix or user
usr
Home directories of all users
...
An external command is a UNIX command that exists independently as a separate file
...
g
...
a
...
The shell program searches this command file using a system variable called “PATH" variable
...
They are the part of some other program or
some other routine
...
g
...
are the examples of internal commands
...
Explain different blocks in UNIX
...
1
...
Super block
3
...
Data block
1
...
It contains a program called boot strup loader
...
Although, one boot block is required to start up the system
...
2
...
The super block describes the state of the file
system like how large it is, how many files it can hold, how many more files can be created, etc
...
Inode block
Entire UNIX entities are treated as files
...
For each file there is an inode entry in the table
...
2/1/2016 9:04 AM
Theory
Group of the owner
http://www
...
com/virtim/index
...
Type of the file
File access permission
Date and time of last access
Date and time of last modification
4
...
An allocated block can belong to only one file
...
Explain the anode block in detail?
Each inode entry in the inode table consists of is address
...
So the addresses 0-9 can handle a file
of maximum size of 10kb
...
The remaining addresses 10, 11,
12 which are used to hold the location number of another subdivide block
...
5 of 15
2/1/2016 9:04 AM
Theory
http://www
...
com/virtim/index
...
What are the different types of file permissions and how to change the permission?
There are 3 types of permission to a file
...
Read(R)
2
...
Execute(x)
There are 3 entities to which any combinations of these permissions are assigned
...
These permissions can be encoded numerically
...
The meaning of this 745 is:
7-> Owner,
Ie; owner can perform Read (4), Write (2), and Execute (1) operations
...
5-> Others
Ie; Everybody can perform Read(4), Execute(1) operations
...
File permission can changed by
using a command,
Chmod
...
Now, if we want to change the permission to 744 then we
have to follow the following
6 of 15
2/1/2016 9:04 AM
Theory
http://www
...
com/virtim/index
...
Chmod 744 sample
744 means, we are changing the file permission of sample ie;
7---> Owner
I
...
owner can perform Read(4), Write (2), Execute(1) operations
...
e Group can perform Read(4) only operations
...
e Other can perform Read(4) only operations
...
Umask stands for user file creation mask
...
The curren value of umask can be easily determined by typing:
$Umask
o/p ---> 0022
1st number represents that it is octal number
...
We can change the Umask values as follows:
$umask
Eg: $umask 531
Process Management
What is process management? Explain different types of process states
...
The lifetime of the process can be divided into a number of states
...
New state
The process is created
ii
...
iii
...
Ready state
The process is waiting to be allocated to a processor
...
Terminated
http://www
...
com/virtim/index
...
The process terminates after finishing its execution
...
The process that generates another process is called parent process
...
Example:
$cat file1
Here shell is parent process and cat is the child process
...
Child process is cat and wc
...
What are different types of rules when a process is creating?
The original process is called parent process
...
In UNIX a process can create a child process
using the system called fork()
...
The successfully execution of the fork() system call will
return 0, else it will return -1
...
What are different types of process in UNIX?
In UNIX, process can be classified into 3 categories i
...
interactive or foreground process, non-interactive or background
process and daemon process
...
Foreground process / interactive process
All the user processes that are created by users using shell and executed in the terminal are known as interactive or
foreground process
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
The shell and the user
have to wait for the kernel to complete the execution
...
Advantage
The main advantage of interactive or foreground process is that no further commands can be issued as long as the older one
is under execution
...
2
...
Such processes are known as non-interactive or background process
...
Example:
Whenever a user gives a command for sorting a large database or searching a particular file from a large file system using
the “find" command, the command can be made to run in the background as background process by adding an
ampersand (&) character as follows:
$sort file1 file2 &
3
...
After that the
daemon process will run constantly till the system becomes idle / switch off
...
The main characteristics of daemon process are as follows:
Daemon process cannot be killed permanently
...
Lifetime is as long as system is running
...
The ps command displays all the current processes that are running inside the system
...
A simple ps command without argument
...
PID (Process id): PID is unique identification of a process
...
tty: Terminal number where the process is running
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
TIME: Total time for the process to complete its execution (Burst time)
...
a
...
The informations are:
User id, PPID (present PID), PID, tty, stime (starting time), etc
...
Ps "e"
This command shows all the processes including the system processes running on the system
...
Ps "a"
This command shows all the user processes but not the system processes
...
When a user logs out with one or more background processes running which is an unnatural death
...
Therefore nohup
command lets the user to run a program continuously even after the user has logged out
...
dat xyz
...
Kill command is used to terminate the process forcefully
...
A particular process can be killed by giving its PID (process id)
...
Write a brief note about fork()
...
When fork() is executed it will return one unique PID for the child process i
...
when a process is forked, the child gets a new
PID
...
The fork() is used to create a child process only
...
To start execution for a child process, parent process calls another system call i
...
exec()
...
Sometimes it is required to stop a process execution temporarily
...
To start a process which is stopped temporarily the parent process will invoke another system call i
...
init() or exec()
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
When the child process completes its execution, another system call will be invoked for termination i
...
exit()
...
Write ()
Communication
It allows a two way communication between two users who are currently logged-in and who has given write permission
...
They want to communicate with each other
...
Write permission
b
...
Mesg ()
Mesg () is used to get the permission from two users who wants to communicate
...
It can be used to send a message to all the users which is known as broadcasting
message to all the users
...
It enables the administrator to sent a message to all the user whether they have given the write permission or not
...
The typical activities performed by a shell as
interpreter are:
The shell prompt waits for the user to enter a command
...
It transfers the command line to kernel for execution
...
After execution, shell will reappear and will be ready to start next cycle
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
The Bourne shell (sh)
...
C shell (csh)
...
Korn Shell (ksh)
...
Therefore shell variables have the
ability to store and manipulate information within the program
...
It must start with an alphabet or an underscore (_)
...
There is no limit to the length of the variable name
...
Shell variables do not have different data types
...
The contents of data types are stored in
ASCII format
...
Hence it is not required to initialize shell variables
...
Example: #this is comment
Keywords
Keywords are words with predefined meaning
...
Examples:
echo if until
trap read else
case wait readonly
fi esac eval
set while break
exec unset do
continue ulimit shift
done exit umask
export for return
Rules for Arithmetic Operation
Multiple arguments can be done in a single line
...
g
...
e
...
$expr -20 % 3 Multiplication sign (*) must always be preceded by a \ (as \*)
...
The types of control structures are:
Control Structures
If-then-fi statement
If-then-else-fi statement
If-then-elif-else-fi statement
Case-esac statement
12 of 15
2/1/2016 9:04 AM
Theory
http://www
...
com/virtim/index
...
1
...
...
g
...
If-then-else-fi statement
Syntax:
if [condition ]
then
statement 1
statement 2
Statement 5
else
statement 6
statement 7
fi
e
...
if [ $a -ge $b ]
then
echo "a is greater";
else echo "b is greater";
fi
3
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
g
...
Case-esac statement
Syntax:
Case
choice 1) statement 1
statement 2
choice 2) statement a
statement b
default *) statement i
statement ii
esac
e
...
n=2
case $n in
1) echo "I am case one";
2) echo "I am case two";
3) echo "I am case three";
*) echo "I am default";
esac
Loop Control Structure
1
...
for loop
3
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
g
...
valn)
do
statement 1
statement 2
done
e
...
for i in 1 2 3 4 5
do
echo $i
done
Until loop
Syntax:
Initialization
Until [condition ]
do
statement 1
statement 2
Increment/decrement
done
e
...
i=1
until [$i -ge 5 ]
do
echo $i
i = `expr $i + 1`
done
15 of 15
operating system, (/virtim/index
...
php/component/tags/tag/7-unix)
unix notes, (/virtim/index
...
php/component/tags/tag/9-linux)
2/1/2016 9:04 AM
Shell Scripts
clear
http://www
...
com/virtim/index
...
TO COUNT THE NUMBER OF CHARACTERS IN A STRING
echo "Enter the word"
cat>test
len=`cat test | wc -c`
len=`expr $len - 1`
echo "The length of the word entered is:"
echo $len
echo
clear
2
...
echo "Enter a year(yyyy)"
read year
R=`expr $year % 4`
if [ $R -eq 0 ]
then
echo "$year is a leap year"
else
echo "$year is not a leap year"
fi
3
...
clear
echo "enter the number to check"
read num
if [ `expr $num % 2` -eq 0 ]
then
echo "$num is even number"
else
echo "$num is odd number"
fi
4
...
clear
echo "Enter the number"
read num
fact=1
i=1
while [ $i -le $num ]
1 of 6
2/1/2016 9:05 AM
Shell Scripts
do
http://www
...
com/virtim/index
...
fact=`expr $fact \* $i`
i=`expr $i + 1`
done
echo "The factorial of $num is:"
echo $fact
5
...
clear
echo "Enter the string"
cat>str
len=`cat str | wc -c`
len=`expr $len - 1`
row=2
col=0
while [ $len -gt 0 ]
do
ch=`cut -c $len str`
tput cup $row $col
echo $ch
len=`expr $len - 1`
col=`expr $col + 1`
done
echo
6
...
clear
echo "Enter the string"
cat>str
len=`cat str | wc -c`
len=`expr $len - 1`
count=0
while [ $len -gt 0 ]
do
ch=`cut -c $len str`
case $ch in
A|a)count=`expr $count + 1`
;;
E|e)count=`expr $count + 1`
;;
I|i)count=`expr $count + 1`
;;
O|o)count=`expr $count + 1`
2 of 6
2/1/2016 9:05 AM
Shell Scripts
http://www
...
com/virtim/index
...
;;
U|u)count=`expr $count + 1`
;;
*);;
esac
len=`expr $len - 1`
done
echo "The number of vowels are:"
echo $count
7
...
To check if a string is palindrome or not
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
To zip and unzip files
...
To implement UNIX commands
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
TAIL"
echo "2
...
CMP"
echo "4
...
rm -r $dir
echo "directory $dir deleted successfully"
break
;;
*) echo "INVALID ENTRY
...
To display all files in the current directory
...
virtim
...
php/2015-05-26-07-47-04/2015-05-
...
Â
6 of 6
unix, (/virtim/index
...
php/component/tags/tag/10-lab)
unix lab, (/virtim/index
...
php/component/tags/tag/12-unix-program)
shell script, (/virtim/index
Title: Unix Operating System
Description: This PDF contains full explanation of Unix Operating System. This PDF had theory as well as shell scripts which can be very useful and for understanding Unix OS
Description: This PDF contains full explanation of Unix Operating System. This PDF had theory as well as shell scripts which can be very useful and for understanding Unix OS