writing a shell script of commands

Can anyone help me out in visualizing on what is the logic behind simple unix commands. For Eg: ls command lists files and directories, how it displays I need to know the source code for commands like this.

Double post?

UNIX is mostly written in C, you may want to delve into kernel programming in order to get your question answered.