I know, the question of how to cite source code has been asked before, but I did not found anything helpful for my specific situation.

I am currently writing my master's thesis. My university does not dictate any particular citation style so I just use biblatex's default settings. My work is quite OS-specific, so I have to cite Linux source code on several places throughout.

I found the Linux cross reference, which allows me to reference specific code lines for specific Linux versions. I intent to use this for my purpose, so I will cite URLs in the form of http://lxr.free-electrons.com/source/<filepath>?v=<version>#L<linenumber>. However, I do not know how to exactly do this.

I know biblatex provides the online type which should be generally applicable, since I am citing URLs. I have two problems with this, though:

  1. What do I fill in as the author/editor? Linux is written by hundreds of people and surely there would be no benefit in mentioning them all. Should I drop the editor/author and instead fill in the organization? But then, do I refer to the Free Software Foundation holding the copyright to Linux Linux Foundation or rather to the maintainers of the Linux cross reference?
  2. I feel like a larger amount of such source code references would clutter the bibliography. Hence, I would rather have an extra section (like a secondary bibliography) listing only those source code references. Is there a solution for this use case? Or should I save the effort and accept the cluttering?
  • 6
    The official github repository looks like a more stable and authoritative source than the website you suggest. – Federico Poloni Jun 30 '15 at 10:40
  • Didn't know you could reference lines in github too. But with Federico's solution I don't need to be doing this anyhow. So I guess I will be using the github repo with Linus as author. – j0ker Jun 30 '15 at 10:54
  • You can get links to individual lines by clicking on the line number in the source code view. If you are viewing the current version of a file, by pressing y you can turn the link into a permalink containing the commit SHA. – Federico Poloni Jun 30 '15 at 12:15
  • 5
    The only official aspect to the GitHub repository is that it is maintained by Torvalds himself. The official Linux kernel repository is there: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git – sleblanc Jun 30 '15 at 13:44

In my mind, I see the Linux source code as a single bibliography entry (possibly with its official kernel.org repository as the source URL). You can refer to the different files in the text as \cite[Version~4.1, \texttt{drivers/android/binder.c}, Line~18]{Linux}.

EDIT: suggested kernel.org instead of github, as pointed out by bdsl, sebleblanc and Bruno.

  • I really like this solution. It avoids the too-many-references problem and at the same time sets code citations apart from normal citations. Thanks! – j0ker Jun 30 '15 at 10:51
  • 6
    I'd use the kernel.org repository, which seems a bit more official. – Bruno Jun 30 '15 at 12:57
  • @Bruno Good point. AFAIK kernel.org doesn't have line-by-line permalinks, but if one isn't going to use them anyway it is a more authoritative choice. – Federico Poloni Jun 30 '15 at 15:47
  • 2
    @FedericoPoloni, It looks like there's an anchor for every line (accessible from the number on the left) on kernel.org too. For example: git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/… – Bruno Jun 30 '15 at 15:51
  • 1
    @Bruno Oh - I am embarrassed I missed them. Ok, then I agree with you, kernel.org trumps github on all accounts. – Federico Poloni Jun 30 '15 at 15:52

In APA style (6th ed., section 7.08), the reference should look something along the lines of

Linus Torvalds (2015). Linux (4.1-rc8) [Operating system]. Retrieved from https://github.com/torvalds/linux/releases/tag/v4.1-rc8


  1. Linus Torvalds' role is something like the editor or publisher of Linux.
  2. You should have just the one entry in the reference list to the source code as a whole; individual places where you cite particular lines of code should be cited where you refer to them, either in the text or as a footnote.
  • 9
    I think kernel.org is the primary website for Linux, not github. Linus Tovalds keeps an additional copy on github for convenience. Maybe it doesn't matter which one is cited though. – bdsl Jun 30 '15 at 11:35
  • @bdsl - kernel.org would work as well, but you won't find release candidates there. – Charles Stewart Jun 30 '15 at 13:36
  • @CharlesStewart, really? the main page and the refs page list a number of -rc tags, for example this one (as of today). – Bruno Jun 30 '15 at 14:49
  • 2
    Would you really cite Linus Torvalds as the author if he didn't author the files/lines referenced by the paper? For example, kernel/time/ntp.c has many authors, none of which are Linus. Would Linus Torvalds still be the one to cite if referencing something specific to this file? – Cornstalks Jun 30 '15 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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