-2

I'd like to know where the source code for the commands are in the linux tree.

Some commands:

  • mkdir
  • ls
  • dir
  • chmod
  • etc

Right now I'd just like to read the code and understand it, I know there are many more steps in understanding how linux works, but right now I really want to understand how the OS receives the command and how it calls the correct command

4
  • I'm confused about why this is getting downvoted so heavily. It certainly seems like a reasonable question. Commented Apr 28, 2013 at 6:50
  • I guess there are a lot of answers google turns up: stackoverflow.com/questions/11528267/… Commented Apr 28, 2013 at 6:53
  • @tigger Yeah .. probably. English isn't my first language so I didn't really know how to look for this information, but when I tried I didn't find anything that I actually wanted, so I decided to post my question ... apparently it wasn't a good decision for my reputation :) Commented Apr 28, 2013 at 7:46
  • No worries, yeah just type "source code for linux commands" and you'll get a number of results. Commented Apr 28, 2013 at 7:47

2 Answers 2

3

Download the source of coreutils from http://www.gnu.org/software/coreutils/ and get started. Get the source of bash http://ftp.gnu.org/gnu/bash/ (or other shell) and you can read the bash source.

You may want to read any Linux system programming book to read about the system calls API and know how to use them. Here is a link to unix.stackexchange: What is the best book to learn Linux system programming?

The working of the Linux OS and working of the commands are different things. If you already know OS basics then you can try reading Understanding The Linux Kernels by Daniel Bovet. Else I think you might want to first read a standard OS book by Galvin, Tanenbaum or Deitel or any other book.

Sign up to request clarification or add additional context in comments.

1 Comment

BTW, ls --help outputs a quite long text ending by a mention of GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
2

You might find it easier to start with some older Unix source code (primarily because the programs were smaller and simpler before 40 years of creature feepism happened). There's a lot available at The Unix Heritage Society. This directory has the source to all Unix commands from the 7th Edition of Unix. The language is K&R C but it's quite readable.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.