Linux, to be pedantic, is just a kernel. You can find the source for that @
The Linux Kernel Archives. However, that does not include all of the bits that make a linux distribution a usable operating system. The source for the shells, toolchain, and the usual userland suspects (cat, head, cp, mv, etc ...) are located elsewhere. Most of those peripheral yet crucial tools are developed by the gnu project; for example, GNU Coreutils @
Coreutils - GNU core utilities.
If GNU/Linux source is not required, if instead you're interested in UNIX in general, you will find that browsing and studying *BSD source is a lot simpler. A BSD project develops its kernel, C library, and standard utilities as part of one consolidated development effort (with the notable exception that they depend on the GNU C compiler toolchain), while the linux kernel, the GNU C library, and the standard utilities which form the core of a linux distro are each developed by different people.
For a *BSD system, all of the source is available in one central repository, while the original sources for a GNU/Linux distro are many and scattered. If you're using linux and your distribution's package manager does not make source available, you will need to track down the sources of its source independently.
A bonus for beginners is that the BSD sources are simpler than their GNU equivalents. While a BSD project's code only needs to support their own operating system, GNU tools, not being part of a larger system, endeavour to support many operating systems. Further, GNU projects tend to be more cavalier about extending the POSIX standard. In conjunction, these lead to GNU code being more complicated and difficult to understand than its BSD equivalents.
A typical example (I did not cherry-pick an aberration), the "simple" head(1) utility, which by default reads the first ten lines of input and exits:
OpenBSD head.c: ~100 lines:
src/usr.bin/head/head.c - annotate - 1.15
GNU head.c: ~1000 lines:
coreutils.git - GNU coreutils
Whatever you choose to study, enjoy. Not many disciplines provide such unfettered access to the work of accomplished practitioners.
Regards,
Alister
P.S. If any of the preceding message seems anti-Linux or BSD-fanboi-ish, it is nothing of the sort. Please re-read it through a neutral lens. I have no agenda. Anyone familiar with both codebases will know that these statements are accurate, objective facts. And, anyone familiar with me knows that it took astounding effort on my part to not mention GNU's 2-space indent style
.