Linux Deep Dive|Part 1

Ankit Tripathi
May 5, 2019

Linux Deep Dive will be a series of articles where I will be writing about linux and digging deep into how things work under the hood. I have published the same article on Medium as well, please give it a read.

Linux Deep Dive

How does the "ls -l" command work?

linux deep dive – how does this command work?

Have you ever thought about it? If not let’s analyze what happens when you execute "ls -l" in your shell

  • When you enter the command ls -l in shell it takes input from get-line() function.
  • Shell will check for alias if there is any alias for ls it will replace with the value.
  • It’s time to find where is ls binary ? so shell will look in $PATH environment variable which contains array of directories separated by : PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
  • Every time we enter a command the shell searches in above directory for executables.
  • finally we found binary in /usr/bin/ls

It’s time to get in kernel space.

Wait a minute. Where were we until now? Shell is an application which runs on user space.

So, what are kernel space and user space?

Memory has two areas

  • The user space, which is a set of locations where normal user processes run.
  • The kernel space, which is the location that manages the execution and storage of the code.

(User space and kernel space communication happens using system call)

linux deep dive – kernel space communication
  • Shell makes fork()  system call to duplicate parent process and create a child process (here parent process is shell).
  • execve() system call is made which take input of ls -l to execute.
  • Below image shows values which get places as input for ls -l command
linux deep dive
Strace output of ls -l

PS: I am using strace command to analyse system call.

In the end, the parent process waits for the child process to execute using wait() system call. After response from execution shell displays the result. For more, please visit

Read our blog on Machine Learning & Neural Networks

Blog Cover Photo by Emmanuel on Unsplash

Kernel Space

About Quinbay

Quinbay is a dynamic one stop technology company driven by the passion to disrupt technology today and define the future.
We private label and create digital future tech platforms for you.

Digitized . Automated . Intelligent