Linux

What happens when you execute ls -l?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

  • Shell reads the input using getline() which reads the input file stream and stores into a buffer as a string

  • The buffer is broken down into tokens and stored in an array this way: {"ls", "-l", "NULL"}

  • Shell checks if an expansion is required (in case of ls *.c)

  • Once the program in memory, its execution starts. First by calling readdir()

Notes:

  • getline() originates in GNU C library and used to read lines from input stream and stores those lines in the buffer