Register your product to gain access to bonus material or receive a coupon.
Linux Programming by Example: The Fundamentals
- By Arnold Robbins
- Published Apr 12, 2004 by Prentice Hall. Part of the Prentice Hall Open Source Software Development Series series.
- Your Price: $35.19
- List Price: $43.99
- Usually ships in 24 hours.
- Copyright 2004
- Dimensions: 7x9-1/4
- Pages: 720
- Edition: 1st
- ISBN-10: 0-13-142964-7
- ISBN-13: 978-0-13-142964-2
“This is an excellent introduction to Linux programming. The topics are well chosen and lucidly presented. I learned things myself, especially about internationalization, and I’ve been at this for quite a while.”
Chet Ramey, Coauthor and Maintainer of the Bash shell
“This is a good introduction to Linux programming. Arnold’s technique of showing how experienced programmers use the Linux programming interfaces is a nice touch, much more useful than the canned programming examples found in most books.”
Ulrich Drepper, Project Lead, GNU C library
“A gentle yet thorough introduction to the art of UNIX system programming, Linux Programming by Example uses code from a wide range of familiar programs to illustrate each concept it teaches. Readers will enjoy an interesting mix of in-depth API descriptions and portability guidelines, and will come away well prepared to begin reading and writing systems applications. Heartily recommended.”
Jim Meyering, Coauthor and Maintainer of the GNU Core Utility ProgramsLearn Linux® programming, hands-on… from real source code
This book teaches Linux programming in the most effective way possible: by showing and explaining well-written programs. Drawing from both V7 Unix® and current GNU source code, Arnold Robbins focuses on the fundamental system call APIs at the core of any significant program, presenting examples from programs that Linux/Unix users already use every day. Gradually, one step at a time, Robbins teaches both high-level principles and “under the hood” techniques. Along the way, he carefully addresses real-world issues like performance, portability, and robustness. Coverage includes:
- Memory management
- File I/O
- File metadata
- Users and groups
- Sorting and searching
- Argument parsing
- Extended interfaces
- And more…
Just learning to program? Switching from Windows®? Already developing with Linux but interested in exploring the system call interface further? No matter which, quickly and directly, this book will help you master the fundamentals needed to build serious Linux software.
Companion Web Sites, authors.phptr.com/robbins and www.linux-by-example.com, include all code examples.
To facilitate your work with the "Suggested Reading" sections of the text, we are providing links to select books and online resources referenced throughout the book.
From Chapter 1
- The C Programming Language, 2nd edition , by Brian W. Kernighan and Dennis M. Ritchie. Prentice-Hall, Englewood Cliffs, New Jersey, USA, 1989. ISBN: 0-13-110370-9. This is the "bible" for C, covering the 1990 version of Standard C. It is a rather dense book, with lots of information packed into a startlingly small number of pages. You may need to read it through more than once; doing so is well worth the trouble.
- C, A Reference Manual, 5th edition, by Samuel P. Harbison III and Guy L. Steele, Jr. Prentice-Hall, Upper Saddle River, New Jersey, USA, 2002. ISBN: 0-13-089592-X. This book is also a classic. It covers Original C as well as the 1990 and 1999 standards. Because it is current, it makes a valuable companion to The C Programming Language. It covers many important items, such as internationalization- related types and library functions, that aren't in the Kernighan and Ritchie book.
- Notes on Programming in C , by Rob Pike, February 21, 1989. Available on the Web from many sites. Perhaps the most widely cited location is http://www.lysator.liu.se/c/pikestyle.html . (Many other useful articles are available from one level up: http://www.lysator.liu.se/c/ .) Rob Pike worked for many years at the Bell Labs research center where C and Unix were invented and did pioneering development there. His notes distill many years of experience into a "philosophy of clarity in programming" that is well worth reading.
- The various links at http://www.chris-lott.org/resources/cstyle/ . This site includes Rob Pike's notes and several articles by Henry Spencer. Of particular note is the Recommended C Style and Coding Standards, originally written at the Bell Labs Indian Hill site.
From Chapter 6
- The Art of Computer Programming Volume 3: Sorting and Searching, 2nd edition , by Donald E. Knuth. Addison-Wesley, Reading Massachusetts, USA, 1998. ISBN: 0-201-89685-0. This book is usually cited as the final word on sorting and searching. Bear in mind that it is considerably denser and harder to read than the Loudon book.
- The GTK+ project consists of several libraries that work together. GTK+ is the underlying toolkit used by the GNU GNOME Project . At the base of the library hierarchy is Glib, a library of fundamental types and data structures and functions for working with them. Glib includes facilities for all the basic operations we've covered so far in this book, and many more, including linked lists and hash tables. To see the online documentation, start at the GTK+ Documentation Project's web site , click on the "Download" link, and proceed to the online version.
From Chapter 9
- Advanced Programming in the UNIX Environment, 2nd edition , by W. Richard Stevens and Stephen Rago. Addison-Wesley, Reading Massachusetts, USA, 2004. ISBN: 0-201-43307-9. This book is both complete and thorough, covering elementary and advanced Unix programming. It does an excellent job of covering process groups, sessions, job control, and signals.
- The Design and Implementation of the 4.4 BSD Operating System , by Marshall Kirk McKusick, Keith Bostic, Michael J. Karels, and John S. Quarterman. Addison-Wesley, Reading, Massachusetts, USA, 1996. ISBN: 0-201-54979-4. This book gives a good overview of the same material, including a discussion of kernel data structures, which can be found in section 4.8 of that book.
From Chapter 11
- Building Secure Software: How to Avoid Security Problems the Right Way , by John Viega and Gary McGraw. Addison-Wesley, Reading, Massachusetts, USA, 2001. ISBN: 0-201-72152-X. This is a good book on writing secure software and it includes how to deal with setuid issues. It assumes you are familiar with the basic Linux/Unix APIs; by the time you finish reading our book, you should be ready to read it.
- "Setuid Demystified," by Hao Chen, David Wagner, and Drew Dean. Proceedings of the 11th USENIX Security Symposium, August 5-9, 2002. http://www.cs.berkeley.edu/~daw/papers/setuid-usenix02.pdf . Garfinkel, Spafford, and Schwartz recommend reading this paper "before you even think about writing code that tries to save and restore privileges." We most heartily agree with them.
From Chapter 12
- Programming Pearls, 2nd edition , by Jon Louis Bentley. Addison-Wesley, Reading, Massachusetts, USA, 2000. ISBN: 0-201-65788-0. See also this book's web site at http://www.cs.bell-labs.com/cm/cs/pearls/ . Program design with assertions is one of the fundamental themes in the book.
- Building Secure Software: How to Avoid Security Problems the Right Way , by John Viega and Gary McGraw. Addison-Wesley, Reading, Massachusetts, USA, 2001. ISBN: 0-201-72152-X. Race conditions are only one of many issues to worry about when you are writing secure software. Random numbers are another. This book covers both, among other things. (We mentioned it in the Chapter 11.)
- The Art of Computer Programming: Volume 2: Seminumerical Algorithms, 3rd edition , by Donald E. Knuth. Addison-Wesley, Reading, Massachusetts, USA, 1998. ISBN: 0-201-89684-2. See also the book's web site at http://www-cs-faculty.stanford.edu/~knuth/taocp.html . This is the classic reference on random number generation.
From Chapter 13
- C: A Reference Manual, 5th edition , by Samuel P. Harbison III and Guy L. Steele, Jr., Prentice-Hall, Upper Saddle River, New Jersey, USA, 2002. ISBN: 0-13-089592-X. We have mentioned this book before. It provides a concise and comprehensible description of the evolution and use of the multibyte and wide-character facilities in the C standard library. This is particularly valuable on modern systems supporting C99 because the library was significantly enhanced for the 1999 C standard.
- GNU gettext tools, by Ulrich Drepper, Jim Meyering, Francois Pinard, and Bruno Haible. This is the manual for GNU gettext. On a GNU/Linux system, you can see the local copy with 'info gettext'. Or download and print the latest version (from ftp://ftp.gnu.org/gnu/gettext/ ).
From Chapter 15
- Programming Pearls, 2nd edition , by Jon Louis Bentley. Addison-Wesley, Reading, Massachusetts, USA, 2000. ISBN: 0-201-65788-0. See also this book's web site at http://www.cs.bell-labs.com/cm/cs/pearls/ . Chapter 5 of this book gives a good discussion of unit testing and building test scaffolding.
- The Practice of Programming , by Brian W. Kernighan and Rob Pike. Addison- Wesley, Reading, Massachusetts, USA, 1999. ISBN: 0-201-61585-X.
From Chapter 16
- The UNIX Programming Environment , by Brian W. Kernighan and Rob Pike. Prentice-Hall, Englewood Cliffs, New Jersey, USA, 1984. ISBN: 0-13-937699-2. This is the classic book on Unix programming, describing the entire gestalt of the Unix environment, from interactive use, to shell programming, to programming with the <stdio.h> functions and the lower-level system calls, to program development with make, yacc, and lex, and documentation with nroff and troff. Although the book shows its age, it is still eminently worth reading, and we highly recommend it.
- The Art of UNIX Programming , by Eric S. Raymond. Addison-Wesley, Reading, Massachusetts, USA, 2004. ISBN: 0-13-142901-9. This is a higher-level book that focuses on the design issues in Unix programming: how Unix programs work and how to design your own programs to fit comfortably into a Linux/Unix environment. While we don't always agree with much of what the author has to say, the book does have considerable important material and is worth reading.
Online Sample Chapters
Downloadable Sample Chapter
Download the Sample
Chapter related to this title.
Table of Contents
Audience. What You Will Learn. Small Is Beautiful: Unix Programs. Standards. Features and Power: GNU Programs. Chapter Summary. Typographical Conventions. Where To Get Unix and GNU Source Code. Unix Code. GNU Code.
The Linux/Unix File Model. The Linux/Unix Process Model. Standard C vs. Original C. Why GNU Programs Are Better. Portability Revisited. Suggested Reading. Summary. Exercises.
2. Arguments, Options, and the Environment
Option and Argument Conventions. Basic Command Line Processing. Option Parsing: getopt() and getopt_long(). The Environment. Summary. Exercises.
3. User-Level Memory Management
Linux/Unix Address Space. Allocating Memory. Summary. Exercises.
4. Files and File I/O.
Introduction. Basic Program Structure. Determining What Went Wrong. Input and Output. Random Access: Moving Around Within A File. Creating Files. Forcing Data to Disk. Setting File Length. Summary. Exercises.
5. Directories and File Metadata.
Directory Contents. Creating and Removing Directories. Reading Directories. File Types and Information. Changing Ownership, Permission, and Modification Times. Summary. Exercises.
6. General Library Interfaces - Part 1
Times and Dates. Sorting and Searching. User and Group Names. Terminals: isatty(). Suggested Reading. Summary. Exercises.
7. Putting It All Together: ls.
V7 ls Options. The V7 ls Code. Summary. Exercises.
8. Filesystems and Directory Walks.
Mounting and Unmounting Filesystems. Filesystem Administration Files. Retrieving Per-filesystem Information. Moving Around In The File Hierarchy. Doing A File Tree Walk: GNU du. Changing The Root Directory: chroot(). Summary. Exercises.
9. Process Management and Pipes.
Process Creation and Management. Process Groups. Basic Interprocess Communication: Pipes and FIFOs. File Descriptor Management. Example: Two Way Pipes In gawk. Suggested Reading. Summary. Exercises.
Introduction. Signal Actions. Standard C Signals: signal() and raise(). Signal Handlers In Action. The System V Release 3 Signal APIs: sigset() et al. POSIX Signals. Signals For Interprocess Communication. Important Special Purpose Signals. Signals Across fork() and exec(). Summary. Exercises.
11. User and Group ID Numbers and Permissions.
Introduction. Retrieving User and Group Ids. Checking As The Real User: access(). GLIBC Only: Checking As The E_ective User: euidaccess(). Extra Permission Bits For Directories. Setting Real and E_ective Ids. Linux Only: getresuid() and setresuid(). Setuid root: A Security Minefield. Suggested Reading. Summary. Exercises.
12. General Library Interfaces - Part 2.
Stating Assertions: assert(). Low-level Memory: The memXXX() Functions. Temporary Files. Committing Suicide: abort(). Non-local Gotos. Pseudorandom Numbers. Metacharacter Expansions. Regular Expressions. Suggested Reading. Summary. Exercises.
13. Internationalization and Localization.
Locales and the C Library. Dynamic Translation of Program Messages. Can You Spell That For Me Please? Suggested Reading. Summary. Exercises.
14. Extended Interfaces.
Allocating Aligned Memory: posix_memalign() and memalign(). Locking Files. More Precise Times. Advanced Searching With Binary Trees. Summary. Exercises
What To Do First? Compiling For Debugging. GDB Basics. Programming For Debugging. Debugging Tools. Software Testing. Debugging Rules. Suggested Reading. Summary. Exercises.
16. Tying It Together - A Project.
Project Description. Suggested Reading.
Appendix A. Teach Yourself Programming in Ten Years.
Why is everyone in such a rush? Teach Yourself Programming in Ten Years. References. Answers. Footnotes.
Appendix B. Caldera Ancient UNIX License.
Appendix C. GNU General Public License.
Terms and Conditions for Copying, Distribution and Modification.
How to Apply These Terms to Your New Programs.
ONE MONTH ACCESS!
Get unlimited 30-day access to thousands of Books & Training Videos about technology, professional development and digital media If you continue your subscription after your 30-day trial, you can receive 30% off a monthly subscription to the Safari Library for up to 12 months.