What Happens When You Type “ls -l” in the Shell

Sebastian Toro
2 min readNov 27, 2020

--

Shell it’s a command-line interpreter like an user interface for Unix-like operating systems.

How the terminal looks in Linux Mint

Contrary to other operative systems, the Shell is a way to control the operative systems via commands, this includes create folders, create files, write text and save it, show folder contents and many more. But haven’t you thought what happens when you type any command and hit enter? More specifically the command “ls -l”? The “ls -l” command shows all files in a directory with all his properties.

Example of “ls -l”

What really happens when you type it it’s the following events. The shell saves the command you set in this case “ls” and the parameter “-l”, then using the PATH variable, it searches for the “ls” program [Usually it’s under /bin/ls], then it uses fork() to clone the process to then execute it. ls process loads from LD_PATH [lld /bin/ls], it executes a lot of syscalls [This can be checked using strace] after this the output is printed sends a wait() signal until the parent process dies.

So that’s what passes under the hood when you type “ls -l” and the shell magically shows you all your files

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Sebastian Toro
Sebastian Toro

Written by Sebastian Toro

0 Followers

Currently a Student at Holberton School

No responses yet

Write a response