What happens when you type “ls l” in the Linux shell?

What exactly is a shell in UNIX systems?

Source: http://hpssociety.info/news/shell-in-linux.html
  • In Linux, the shell uses the POSIX API to communicate with the Kernel.
  • The Kernel communicates directly with a computers hardware.

Why is the `-l` flag useful?

  • permissions of a given file
  • number of hard links
  • owner (name)
  • group (name)
  • file size (in bytes)
  • date/time of last modification
  • filename
Source: https://www.guru99.com/must-know-linux-commands.html

How does `ls` actually work?

Source: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/hh184278(v=vs.88)
`lll` is an alias we created
`cd` is a built in command
  • the PATH is passed to the tokenizer strtok() by using the : delimiter to break up the path into tokens.
  • check if the executable exists
  • check for RWX (read, write, execute) permissions, respectively
Source: http://www.it.uu.se/education/course/homepage/os/vt18/module-2/process-management/
  • The parent uses the wait() process to wait for the child() process to finish
  • The child() process uses the execve() function to complete the process and tell the parent process when to start
  • > ls -l → executable /bin/ls → tokenize {“/bin/ls”, “-l”, “NULL”} → (see below)
Result of `ls -l`

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Connor Brereton

I write and sell software ex: @auth0, @onelogin, @cisco, @stanfordGSE