What happens when you run & ldquo; Ls & rdquo; To Bash

advertisements

Can some one provide me a detailed description of what happens when you execute the "ls" command in linux. What system calls are used? What does the file system do? Obviously depending on which file system is used. Is someone can provide an in depth discussion on this topic or point me to some good resources that would be great! Thanks!


  1. current process (we call parent process, or parent) find ls in $PATH variable,eg /usr/bin/ls
  2. parent(process) fork a child( process), and pass all enviroment, child process image is /usr/bin/ls
  3. without arguments, so child find env PWD, eg /foo/bar and excute (/usr/bin/ls /foo/bar)
  4. child process output , exit
  5. parent become interactive again