UNIX Programming: UNIX Processes, Memory Management, Process Communication, Networking, and Shell Scripting
Functioning of UNIX operating system with shell programming
- Equipped with installation, administration, and best practices for UNIX system management.
- Provides a wide range of shell scripting and Unix-based solutions.
- UNIX foundations, Resource Management, Socket Programming, Shell Scripting, and the C Interface are all covered.
This book is intended to be an instructional tool and study guide for those interested in learning about the principles of the UNIX operating system, process management, socket programming, and numerous shell scripting techniques.
First, you will learn about the UNIX system architecture and programming environment, which provide an overview of all system resources and their management. Then, Unix file systems, Kernel data structures for performing file I/O, Basic File permissions and Library functions, and UNIX system calls are discussed. Process control, parallel execution, user data access, and signal management are just some of the topics covered in this book. Next, we’ll go through the basics of network communication, such as system calls, data transmission over sockets, and I/O multiplexing models. Finally, the book discusses more advanced UNIX and C interface concepts such as library functions, command-line arguments, and environment variables.
Throughout the book, you’ll find plenty of solutions, exercises, and shell scripts to help you get the most out of your hands-on experience with the UNIX system.
What you will learn
- Investigate every aspect of the UNIX operating system.
- Understand how to use the shell and how to develop shell scripts.
- Acquaint yourself with all of UNIX’s file and process components.
- Gain a working knowledge of file access and manipulation.
- Learn more about inter-process communication and its many methods.
Who this book is for
The book appeals to UNIX professionals, students, master’s degree applicants, and candidates for competitive exams who wish to understand UNIX principles thoroughly. However, it is written for beginners and may be read by anyone without prior understanding.
Cover Page Title Page Copyright Page Dedication Page About the Authors About the Reviewer Acknowledgement Preface Errata Table of Contents 1. Fundamental Concepts of UNIX Operating System Structure Objectives History of UNIX Salient features of UNIX Portability Multi-tasking Multi-user Device independence Modularity Networking Tools and utilities Security The UNIX system architecture UNIX programming environment Personal environment Time-sharing environment Client-server environment UNIX process Process attributes Process states Modes of execution of a process Process context Process relationship init process in 4.3 BSD init process in UNIX system V Files and directories File Pathname Types of files UNIX file name convention File names and meta characters UNIX file system Important UNIX directories Conclusion Key terms Test your skills Answers Review exercise 2. File Management Structure Objectives File input/output Kernel data structures for file input/output System call for UNIX file I/O BASIC file permission Real and effective user-IDs and group-IDs Mounting and unmounting a file system Directory related system calls The mkdir system call The rmdir system call The chdir() system call Standard I/O library in UNIX Stream and FILE object I/O buffering Stream buffering operations Standard data files /etc/passwd file /etc/group file /etc/shadow file Conclusion Review Exercise 3. Process Management Introduction Structure Objectives UNIX process Process IDs Executing process in UNIX environment Modes of execution of a process Process termination Normal termination Abnormal process termination Command-line arguments and environment variables Memory layout of a UNIX process Setting branch into another function Process states Process control block Process control Process creation Awaiting process termination Executing another program Accessing user information User details Group details Show information of all users logged in Process groups Sessions Signals Sending a signal to processes Signal handling Thread Conclusion Review Exercise 4. Inter-Process Communication Introduction Structure Objective Introduction to IPC Means of interprocess communication Pipes and FiFOs One end closed pipe The popen() I/O library function The pclose() I/O function FIFOs Server process Client process Message queues Destroying a message queue Controlling message queue Shared memory Creating shared memory Controlling a shared memory segment Attaching and detaching a shared memory segment Process synchronization Semaphores Semaphore operations Semaphore set Creating semaphore Controlling semaphore Semaphore operations semop() Destroying a semaphore Conclusion Review Exercise 5. Socket Programming Introduction Structure Objective Socket Types of sockets Socket data structure System calls for socket communication Creating a socket (server and client) Binding socket to an address (server) Listening incoming connection Initiating connection Accepting the connection from the incoming queue Sending data through socket (connection-oriented) Receiving message through socket (connection-oriented) Receiving message through socket (connectionless) Closing socket I/O models Blocking I/O model Non-blocking I/O model I/O multiplexing model Signal-driven I/O model Asynchronous I/O model Name and address conversion Resource records The gethostbyname() function The hostent structure The gethostbyaddress() function The getservbyname() and getservbyport() functions Conclusion Review Exercise 6. Memory Management Structure Objective Memory management Use of operating system memory Memory contents of a running process in UNIX Swapping Demand paging Memory management functions The malloc() function The free() function The calloc() function The realloc() function The alloca() function Setting branch to another function Conclusion Multiple choice questions Answers Questions 7. UNIX Shell and Custom Environment Structure Objectives Introduction to shell Execution modes of UNIX shell Interactive mode Programming mode UNIX session customization mode Shell interpretation cycle Functions of UNIX shell Program execution Input/output redirection Command pipelining Environment customization Shell programming language Types of shells The Bourne shell family The C shell family Summary of features Meta character and wild cards Command standard input/output Redirection Output redirection Safe I/O redirection with noclobber Input redirection Redirecting error Command grouping Command pipelining The tee command UNIX environment variables PATH variable HOME variable Prompt string 1 (PS1) variable Prompt string 2 (PS2) variable MAIL variable CDPATH variable MAILCHECK variable MAILPATH variable User’s profile Conclusion Test your skills Answers Review Exercises Lab practice 8. Shell Programming Using Bourne Shell Structure Objective Introduction to shell programming Writing shell scripts Variables Comment Quoting Single quotes Double quotes The backslash Command substitution Special shell variables The shift command The set command Interactive input Subshell Exporting variables Test operator for comparisons Logical operators with test The negation operator (!) The logical AND operator The logical OR operator Control commands Conditional if Conditional case The while command The until command The for command The break command The continue command Special string operations Parameter substitution Functions Passing arguments to function Returning from function Trapping signals Arrays Conclusion Review Exercise Index
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.