DIGITAL NOTES ON LINUX PROGRAMMING (R17A0525) B.TECH III YEAR - I SEM (2019-20) DEPARTMENT OF INFORMATION TECHNOLOGY MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY (Autonomous Institution – UGC, Govt. of India) (Affiliated to JNTUH, Hyderabad, Approved by AICTE - Accredited by NBA & NAAC – ‘A’ Grade - ISO 9001:2015 Certified) Maisammaguda, Dhulapally (Post Via. Hakimpet), Secunderabad – 500100, Telangana State, INDIA. Linux Programming Page 1 MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY III Year B.Tech IT – I Sem L T /P/D C 4 - / - / - 4 (R17A0525)LINUX PROGRAMMING Objectives: To develop the skills necessary for Unix systems programming including file system programming, process and signal management, and interprocess communication. To make effective use of Unix utilities and Shell scripting language such as bash. To develop the basic skills required to write network programs using Sockets. UNIT I Linux Utilities-File handling utilities, Security by file permissions, Process utilities, Disk utilities, Networking commands, Filters, Text processing utilities and Backup utilities. Sed-Scripts, Operation, Addresses. Awk- Execution, Fields and Records, Scripts, Operation, Patterns, Actions. Shell programming with Bourne again shell(bash)- Introduction, shell responsibilities, pipes and Redirection, here documents, running a shell script, the shell as a programming language, shell meta characters, file name substitution, shell variables, shell commands, the environment, quoting, test command, control structures, arithmetic in shell, shell script examples. UNIT II Files and Directories- File Concept, File types, File System Structure, file metadata- Inodes, kernel support for files, system calls for file I/O operations- open, create, read, write, close, lseek, dup2,file status information-stat family, file and record locking-lockf and fcntl functions, file permissions - chmod, fchmod, file ownership- chown, lchown, fchown, links-soft links and hard links – symlink, link, unlink. Directories-Creating, removing and changing Directories-mkdir, rmdir, chdir, obtaining current working directory-getcwd, Scanning Directories-opendir, readdir, closedir, rewinddir, seekdir, telldir functions. UNIT III Process – Process concept, Kernel support for process, process identification, process hierarchy, process states, process control - process creation, waiting for a process, process termination, zombie process, orphan process, system call interface for process management-fork, vfork, exit, wait, waitpid, exec family. Signals – Introduction to signals, Signal generation and handling, Kernel support for signals, Signal function, kill, raise , alarm, pause, abort, sleep functions. UNIT IV Interprocess Communication - Introduction to IPC, IPC between processes on a single computer system, IPC between processes on different systems, pipes-creation, IPC between related processes using unnamed pipes, FIFOs-creation, IPC between unrelated processes using FIFOs (Named pipes),differences between unnamed and named pipes, popen and pclose library functions. Linux Programming Page 2 Message Queues- Kernel support for messages, APIs for message queues, client/server example. Semaphores-Kernel support for semaphores, APIs for semaphores. UNIT V Shared Memory- Kernel support for shared memory, APIs for shared memory, shared memory example.Comparison of IPC mechanisms. Sockets- Introduction to Berkeley Sockets, Client-Server model, Socket system calls for connection oriented protocol and connectionless protocol, example-client/server programs. TEXT BOOKS: 1. Unix System Programming using C++, T.Chan, PHI. 2. Unix Concepts and Applications, 4th Edition, Sumitabha Das, TMH,2006. 3. Unix Network Programming, W.R.Stevens, PHI REFERENCE BOOKS: 1. Linux System Programming, Robert Love, O’Reilly, SPD, rp-2007. 2. Unix for programmers and users, 3rd Edition, Graham Glass, King Ables, Pearson2003, 3. Advanced Programming in the Unix environment, 2nd Edition, W.R.Stevens, Pearson . 4. System Programming with C and Unix, A.Hoover, Pearson. Outcomes: Students will be able to use Linux environment efficiently Solve problems using bash for shell scripting Linux Programming Page 3 MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY INDEX S. No Topic Page no Unit 1 I Introduction to Linux 5 2 I Linux File System 11 3 I Sed command 49 4 I Awk programming 59 5 I Shell Programming 85 6 II File concepts – File Types 107 7 II System call open, create, read, write, close 111 8 III Process concept 127 9 III Signals 145 10 IV Inter Process Communication 158 11 IV Message Queues 165 12 V Shared Memory 173 13 V Sockets 178 Linux Programming Page 4 MALLA REDDY COLLEGE OF ENGINEERING & TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY UNIT-I UNIT I Linux Utilities-File handling utilities, Security by file permissions, Process utilities, Disk utilities, Networking commands, Filters, Text processing utilities and Backup utilities. Sed-Scripts, Operation, Addresses. Awk- Execution, Fields and Records, Scripts, Operation, Patterns, Actions. Shell programming with Bourne again shell(bash)- Introduction, shell responsibilities, pipes and Redirection, here documents, running a shell script, the shell as a programming language, shell meta characters, file name substitution, shell variables, shell commands, the environment, quoting, test command, control structures, arithmetic in shell, shell script examples. Introduction to Linux: Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of Linux is the Linux kernel, an operating system kernel first released 5 October 1991 by Linus Torvalds. Linux was originally developed as a free operating system for Intel x86-based personal computers. It has since been ported to more computer hardware platforms than any other operating system. It is a leading operating system on servers and other big iron systems such as mainframe computers and supercomputers more than 90% of today's 500 fastest supercomputers run some variant of Linux, including the 10 fastest. Linux also runs on embedded systems (devices where the operating system is typically built into the firmware and highly tailored to the system) such as mobile phones, tablet computers, network routers, televisions and video game consoles; the Android system in wide use on mobile devices is built on the Linux kernel. A distribution oriented toward desktop use will typically include the X Window System and an accompanying desktop environment such as GNOME or KDE Plasma. Some such distributions may include a less resource intensive desktop such as LXDE or Xfce for use on older or less powerful computers. A distribution intended to run as a server may omit all graphical environments from the standard install and instead include other software such as the Apache HTTP Server and an SSH server such as OpenSSH. Because Linux is freely redistributable, anyone may create a distribution for any intended use. Applications commonly Linux Programming Page 5 used with desktop Linux systems include the Mozilla Firefox web browser, the LibreOffice office application suite, and the GIMP image editor Basic Features Following are some of the important features of Linux Operating System. Portable - Portability means software’s can works on different types of hardware’s in same way. Linux kernel and application programs support 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 works 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. Linux Advantages 1. Low cost: You don’t need to spend time and money to obtain licenses since Linux and much of its software come with the GNU General Public License. You can start to work immediately without worrying that your software may stop working anytime because the free trial version expires. Additionally, there are large repositories from which you can freely download high quality software for almost any task you can think of. 2. Stability: Linux doesn’t need to be rebooted periodically to maintain performance levels. It doesn’t freeze up or slow down over time due to memory leaks and such. Continuous up- times of hundreds of days (up to a year or more) are not uncommon. 3. Performance: Linux provides persistent high performance on workstations and on networks. It can handle unusually large numbers of users simultaneously, and can make old computers sufficiently responsive to be useful again. 4. Network friendliness: Linux was developed by a group of programmers over the Internet Linux Programming Page 6 and has therefore strong support
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages187 Page
-
File Size-