What Happens When You Type “ls -l” in the Shell
Shell it’s a command-line interpreter like an user interface for Unix-like operating systems.
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.
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