Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am looking for a good ebook (or two) for learning the C programming language, specifically programming in a GNU/Linux environment. I'm not a beginner programmer, but I have almost no experience in this particular area. I need to learn both the fundamentals of C and the GNU toolchain (gcc, gdb, and make).

For the C language side, I know K&R comes highly recommended, but it doesn't seem particularly practical for me given that it won't describe modern best practices, current libraries, or any particulars about GNU/Linux programming.

Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on C Programming in GNU/Linux and covering the GNU toolchain? What about that book makes it special?

share|improve this question

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

migrated from stackoverflow.com Jan 11 '12 at 20:48

This question came from our site for professional and enthusiast programmers.

Everything needs a start. You can start from here –  Sangeeth Saravanaraj Jan 11 '12 at 19:11
I believe that your question is overly broad. But you can check this list –  bacchus Jan 11 '12 at 19:11
add comment

4 Answers

up vote 1 down vote accepted

Beside The K & R book (second edition) and "C: A Reference Manual (Fifth Edition)" that I use like everyone else, I would add "The Linux Programming Interface" by Michael Kerrisk (subtitled "A Linux and UNIX System Programming Handbook").
It covers most of the Linux, GNU, Posix and system V APIs in gory details, with pertinent examples and enlightning explainations. I use it all day long. It's also been an "instant classic": Published in 2011 (and thus quite up-to-date), it's got today 30 "5 stars" customer reviews on amazon.com - and not any single lower rating than 5 stars. I do not know of any other book that ever achieved that unanimous (and relevant) result.
Michael Kerrisk is the maintainer of the Linux man-pages project, and that certainly helps explaining his encyclopedic knowledge of the Linux (and Unix) APIs.

share|improve this answer
Of all the answers I've received, this one comes closest to addressing my needs. The book linked here comes with an ebook (Kindle) edition, is modern, and covers the specifics of GNU and Linux programming. Thank you for also explaining why this book is valuable. It's clearly not intended as an introduction to C programming, though, so I will have to pair this with another book. –  user648855 Jan 26 '12 at 16:36
add comment

First, allow me to dispel your idea that K&R is out of date. It is not. Many have tried, but no one has yet improved on the programming examples and exercises that Brian Kernighan gives. You've seen tons of books claiming they'll teach you C, sometimes in 24 hours. These books are objects of utter scorn in the professional community: full of mistakes and nothing but expensive kindling or doorstops. The best way (I think the ONLY way) is to go through K&R, a work of beautiful art, page by page and do the exercises and understand their subtle messages.

If you can find a book that will teach you make in a clear, concise, correct way, you should keep this priceless treasure locked up tight.

There are some excellent tutorials around the web on gcc (straightforward) and gdb (straightforward but not trivial). Google around and you'll find them. You can recognize the good ones: they come from the CS departments of some universities. Here's a gdb one that I like: http://ace.cs.ohiou.edu/~bhumphre/gdb.html .


share|improve this answer
In the research I've done online before posting this question, I've come across a number of discussions regarding K&R code not adhering to modern coding recommendations. I am sure that reading K&R will no doubt give me a strong grasp of the language, but I need my code to be maintainable by others, and so I'd like to not form coding habits that others will see as poor. My thought was that I would read K&R as perhaps my second book on C. –  user648855 Jan 12 '12 at 15:44
@user648855 - Not your second book. It should be your first. It will thoroughly ground you and make anything you read after that far easier. –  Rob Jan 12 '12 at 16:01
@user648855 -- I don't know what "modern coding recommendations" you refer to, put I can promise you that you cannot go wrong if you follow the plain, simple, obvious, clear K&R style. Yes, it should be your first book: all others of the type are inferior, error-ridden knockoffs. –  Pete Wilson Jan 12 '12 at 20:07
An example is this discussion I found while doing my initial research: news.ycombinator.com/item?id=1900103 . It is not the only place I found criticism of K&R's book, but the criticisms are representative of what I've seen. Now, as someone coming into this with no prior knowledge of the subject, it's difficult for me to evaluate the validity of the criticism; nevertheless, it's enough to give me pause. It's also hard to dismiss the criticism on the basis of some people claiming that nothing important has changed in decades; it just seems unlikely to me. –  user648855 Jan 12 '12 at 21:05
add comment

One of the best books ever besides K&R

Advanced Programming in the Unix Environment

EDIT: I'm not sure how to write what makes this book good as requested in the comments. While it's a professional book, it doesn't attempt to talk down to anyone or use big words for the sake of it. It explains the usage of all the libraries and system calls, what they're used for, examples of their usage, why you shouldn't use some things, POSIX compliance, differences between Unix/BSD/Linux. It's thorough, leaving nothing much for guesswork, but not boring you with excessive detailing.

share|improve this answer
add comment

One serious clairifcation is that The C Programming Language by Brian Kernighan (creator of AWK & Unix, K&R fame) & Dennis Ritchie (inventor of C, and Unix) the second edition (1988) is ANSI C which is different from K&R "pre-ANSI" C code, which is strongly discouraged practices these days (well since 1988 actually).

So K & R, the 2nd edition book, is strongly recommended and encouraged. The pre-ANSI standard C style is not.

Otherwise, follow the commandments (of St. H. Spencer), the C FAQ (from comp.lang.c maintained by Steve Summit) and the most commonly used and current standard C Library reference is C: A Reference Manual, 5th edition (covers C99, published in 2002) by Harbison and Steele.

Additional standards would include POSIX.1 / IEEE 1003.1 2008 and Single Unix Specification, version 4 (2008) and potentially GNU coding standards, or Linux Kernel coding style for GNU / Linux specific oriented development.

Edit: I am not aware of legitimate (licensed) ebook copies of either the C Programming Language or C: A Reference Manual being available. And I don't know of any freely available ebooks on C that I could even vaguely recommend. So visit a public library and use the typically free inter-library loan or buy your own copies, but I still strongly recommend these resources.

share|improve this answer
Thank you for at least acknowledging the crux of my question. So far you're the only one who's actually addressed everything I've asked. I appreciate the effort you've put into this response. –  user648855 Jan 12 '12 at 20:30
@mctylr -- thank you for the very-important clarification: that the second edition of K&R is the correct edition. –  Pete Wilson Jan 13 '12 at 17:32
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.