You can use the Glibc manual as a reference. It's not for absolute beginners, but if you're reasonably fluent in C you should be able to read a section and write a working program.
You can find the source of the GNU tools on the GNU website; the easiest way to get it is to obtain the source packages on your Linux distribution (e.g. apt-get source coreutils
if your distribution uses Debian packaging utilities). I recommend starting with BusyBox rather than the GNU tools. BusyBox is a set of utilities for embedded Linux systems; it's smaller and simpler than the GNU utilities.
You can run strace ls
to see what system calls ls
is making. Note that when you write a program, you don't call system calls directly, you call functions in the C library which make system calls. For things like file manipulations, the C library functions like open
and read
are pretty close to the system calls though.
For learning, a book (on paper) is usually helpful. Advanced Programming in the UNIX® Environment (APUE) is a classic. If you get it, make sure to get the second edition, as the first is quite dated. This book is the reference, but other books may be more suitable for beginners; shop around.