Module 5 Unix
Module 5 Unix
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.
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.
Layer-1: Hardware -
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.
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.
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.
• The system call and library interface represent the border between
user programs and the kernel. System calls look like ordinary function
calls in C programs. Assembly language programs may invoke system
calls directly without a system call library. The libraries are linked
with the programs at compile time.
• The set of system calls into those that interact with the file subsystem
and some system calls interact with the process control subsystem. The
file subsystem manages files, allocating file space, administering free
space, controlling access to files, and retrieving data for users.
• Processes interact with the file subsystem via a specific set of system
calls, such as open (to open a file for reading or writing), close, read,
write, stat (query the attributes of a file), chown (change the record of
who owns the file), and chmod (change the access permissions of a
file).
• The file subsystem accesses file data using a buffering mechanism
that regulates data flow between the kernel and secondary storage
devices. The buffering mechanism interacts with block I/O device
drivers to initiate data transfer to and from the kernel.
• Device drivers are the kernel modules that control the operator of
peripheral devices. The file subsystem also interacts directly with
“raw” I/O device drivers without the intervention of the buffering
mechanism. Finally, the hardware control is responsible for handling
interrupts and for communicating with the machine. Devices such as
disks or terminals may interrupt the CPU while a process is executing.
If so, the kernel may resume execution of the interrupted process after
servicing the interrupt.
• Interrupts are not serviced by special processes but by special
functions in the kernel, called in the context of the currently running
process.
Difference between Unix and Linux
Linux is essentially a clone of Unix. But, basic differences are shown below:
Linux Unix
The source code of Linux is freely The source code of Unix is not freely
available to its users available general public
Linux Unix
mv file1.txt
Moves files or directories.
mv Documents/
• File Manipulation Unix Command
Command Description Example
mv file1.txt
Moves files or directories.
mv Documents
ln -s target_file
Creates links between files.
ln symlink
diff file1.txt
Compares files line by line.
diff file2.txt
killall -9
Terminates processes by name.
killall firefox
renice -n 10
Changes the priority of running processes.
renice <pid>
sed
Processes and transforms text
's/old_string/new_string/g'
streams.
sed file.txt
+ S and Ctrl + X,
then Ctrl + C to exit