[go: up one dir, main page]

0% found this document useful (0 votes)
25 views10 pages

Unix Progrmng

Uploaded by

Sahitee Basani
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)
25 views10 pages

Unix Progrmng

Uploaded by

Sahitee Basani
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/ 10

UNIX PROGRAMMING

UNIT I
Unix is a powerful, multiuser, and multitasking operating system that was originally developed in
the 1960s at Bell Labs by Ken Thompson, Dennis Ritchie, and others. It is the foundation for
many other operating systems, including Linux, macOS, and even the underlying system for
Android. Unix's design is centered around simplicity and modularity, which allows users to
perform complex tasks by combining simple tools.

Features of UNIX Operating System:


Let's discuss the features of UNIX OS one by one in detail.

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 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.
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.

RT Examples
The architecture of Unix systems is designed to be modular, efficient, and flexible. It consists of several key
components that work together to provide a stable and powerful operating environment. Here’s an overview of
Unix architecture with real-time examples:

1. Kernel

Description: The kernel is the core component of the Unix operating system. It manages hardware resources,
provides system services, and enforces system security. The kernel handles tasks such as process management,
memory management, device management, and system calls.

Real-Time Example:

 Example: A Linux-based server running a web application uses the kernel to manage multiple
simultaneous user requests. The kernel allocates CPU time, manages memory, and handles I/O
operations to ensure that the web server can handle high traffic efficiently.

2. Shell

Description: The shell is the command-line interface (CLI) that allows users to interact with the operating
system. It interprets user commands and executes them by invoking system calls to the kernel. Shells can be
interactive (command line) or script-based (shell scripts).

Real-Time Example:

 Example: A system administrator uses the Bash shell to automate routine tasks by writing shell scripts.
For instance, a script that backs up critical data daily by copying files from a server to a remote storage
location is executed via the shell.

3. File System

Description: The file system organizes and manages files and directories on disk. It provides a hierarchical
structure where files are stored in directories, and it handles file operations like reading, writing, and permission
management.

Real-Time Example:

 Example: On a Linux desktop, the file system manages user files in the /home directory. For instance, a
user’s documents, images, and configuration files are all organized in subdirectories under
/home/username.
4. System Calls

Description: System calls are the programming interface between user applications and the kernel. They allow
user programs to request services from the kernel, such as file operations, process control, and communication.

Real-Time Example:

 Example: A text editor application uses system calls to open, read, and write files. When a user saves a
document, the editor makes system calls to write data to the file system.

5. Processes and Threads

Description: Processes are instances of running programs. Each process has its own memory space and
resources. Threads are lightweight processes within a process that share the same memory space but can
execute independently.

Real-Time Example:

 Example: A web server like Apache runs multiple processes to handle different client requests
simultaneously. Each process can create threads to manage individual connections, allowing the server
to handle many requests efficiently.

6. User and Group Management

Description: Unix systems manage users and groups to control access to files and system resources. Each user
has a unique user ID (UID), and groups have unique group IDs (GIDs). Permissions are assigned based on users
and groups.

Real-Time Example:

 Example: In a multi-user environment, such as a university computer lab, each student has their own
user account. The system administrator assigns permissions so that students can only access their own
files and directories, ensuring privacy and security.

7. Inter-Process Communication (IPC)

Description: IPC mechanisms allow processes to communicate and synchronize with each other. Common IPC
methods include pipes, message queues, semaphores, and shared memory.

Real-Time Example:

 Example: A web application might use IPC to coordinate between a web server process and a database
process. For instance, a message queue could be used to send queries from the web server to the
database for processing.
8. Device Drivers

Description: Device drivers are specialized programs that allow the kernel to interact with hardware devices.
They provide the necessary interface between the hardware and the operating system.

Real-Time Example:

 Example: A Linux server uses device drivers to manage network interfaces. When data is transmitted
over the network, the network device driver handles communication between the network card and the
kernel.

9. Libraries

Description: Libraries are collections of precompiled routines that applications can use. They provide standard
functions and routines to perform common tasks, such as mathematical operations or file handling.

Real-Time Example:

 Example: A software application on a Unix-based system might use the GNU C Library (glibc) for
standard functions such as memory allocation and string manipulation, simplifying development and
ensuring compatibility across different systems.

10. Configuration Files

Description: Configuration files store settings and preferences for the operating system and applications. They
are typically located in the /etc directory and are used to customize system behavior.

Real-Time Example:

 Example: A system administrator configures network settings in the /etc/network/interfaces file


on a Debian-based system. Changes to this file control how the system connects to and configures
network interfaces.

Summary

Unix architecture is designed to be modular and efficient, with components that work together to provide a
stable and secure operating environment. From managing hardware resources with the kernel to interacting with
users through the shell and handling files with the file system, each part of the Unix architecture plays a critical
role in supporting a wide range of real-time applications and use cases.
Unix is a versatile operating system widely used across different domains due to its stability, security, and
flexibility. Here are some real-time examples of where Unix is used:

1. Web Servers

 Use Case: Hosting websites and web applications.


 Example: Companies like Facebook, Google, and Amazon use Unix-based systems (often in the form
of Linux, a Unix-like OS) to run their web servers. Unix's stability and performance make it ideal for
handling the massive traffic and requests these websites receive.
 Reason: Unix systems can handle large numbers of simultaneous connections, and they are highly
configurable, which allows fine-tuning for performance and security.

2. Database Servers

 Use Case: Managing large-scale databases that store critical business information.
 Example: Oracle Database often runs on Unix-based systems because of their ability to handle high
transaction volumes and ensure data integrity. Financial institutions, for example, use these systems to
manage their databases securely and efficiently.
 Reason: Unix’s strong multitasking and multiuser capabilities allow it to handle complex database
operations without downtime.

3. Supercomputing and High-Performance Computing (HPC)

 Use Case: Performing complex calculations and simulations.


 Example: Research institutions and government agencies use Unix-based systems (like Linux) in
supercomputers for tasks such as weather forecasting, scientific research, and cryptographic analysis.
For instance, NASA uses Unix-based systems for their computational needs.
 Reason: Unix’s ability to efficiently manage large-scale parallel processing makes it suitable for HPC
environments.

4. Networking and Internet Infrastructure

 Use Case: Managing network services and infrastructure.


 Example: Unix is commonly used for running DNS servers, email servers (like Sendmail and Postfix),
and FTP servers. Internet service providers (ISPs) and telecom companies rely on Unix systems to
maintain their networking services.
 Reason: Unix's powerful networking tools and commands make it ideal for managing and
troubleshooting network services.

5. Development Environments

 Use Case: Software development and testing.


 Example: Developers use Unix-based systems for programming in languages like C, C++, Java, Python,
and Perl. Many development environments and integrated development environments (IDEs) are
optimized for Unix. Companies like Red Hat and IBM use Unix systems for their development and
testing.
 Reason: Unix offers a rich set of development tools, including compilers, debuggers, and version
control systems, which are essential for software development.
6. Academic and Research Institutions

 Use Case: Education and research.


 Example: Universities and research institutions use Unix systems for teaching computer science and
conducting research. The Unix environment is particularly useful for students learning about operating
systems, networking, and software development.
 Reason: Unix's command-line interface and extensive documentation make it an excellent learning tool
for understanding the fundamentals of computing.

7. Cybersecurity

 Use Case: Penetration testing and security research.


 Example: Security professionals use Unix-based systems (such as Kali Linux) for penetration testing,
vulnerability scanning, and other security-related tasks. These tools are essential in identifying and
mitigating security risks in networks and systems.
 Reason: Unix's flexibility and powerful command-line tools allow security professionals to perform
deep analysis and testing on systems.

8. Embedded Systems

 Use Case: Operating system for embedded devices.


 Example: Unix-based systems are used in embedded devices like routers, smart TVs, and even
automotive systems. For example, many network routers run on Unix-like operating systems.
 Reason: Unix’s modularity and lightweight nature make it suitable for embedded systems that require a
reliable and efficient OS.

9. Cloud Computing

 Use Case: Managing and deploying cloud infrastructure.


 Example: Cloud service providers like AWS, Google Cloud, and Microsoft Azure offer Unix-based
virtual machines for running applications in the cloud. Enterprises use these systems to deploy scalable
cloud applications.
 Reason: Unix-based systems provide the stability and flexibility needed to scale applications in cloud
environments efficiently.

10. Shell Scripting and Automation

 Use Case: Automating repetitive tasks.


 Example: System administrators use Unix shell scripts to automate tasks like backups, system
monitoring, and user management. This automation is crucial in maintaining large-scale IT
environments.
 Reason: Unix’s powerful shell environment allows the creation of scripts that can automate complex
sequences of tasks, saving time and reducing the potential for human error.

Unix's versatility and reliability make it an indispensable tool across various industries and applications, from
powering the internet to driving scientific research and managing enterprise IT infrastructure.

You might also like