What happens when I Type ls -l *.c under the hood.

What happens when I Type ls -l *.c under the hood.

The objective of this article is to talk a bit about ehat happens under the hood when we execute commands in the shell, but mainly we will talk about what happens when we execute 'ls'. The role of the shell is to?interpret?the input provided by the user, and provide output in response to be displayed by the terminal. The most obvious output produced by the shell is the?prompt, which typically looks like this:

No hay texto alternativo para esta imagen

This is just a sign indicating that a new has started, this sign could be any other sign, but this is the most common, in the other cases the '#' sign is used, or as I said before any other sign or text. After that you can put the command designed for the program to do whatever you want to do, for example ls -l *.c Which makes a detailed list of all the .c files in the current directory, something like this:

No hay texto alternativo para esta imagen

What really happens when we execute this command are a series of checks to see if it is a "built in" command or it is not, in the event that it was not a command (! Built in), it would look for the program in the path, where it is checking in which of all the existing directories, is the program that executes the 'ls' line.

But when I talk about path, I don't mean this:

No hay texto alternativo para esta imagen

What I really mean is a set of directories where the program files are located, and actually it looks like this:

No hay texto alternativo para esta imagen

The way to get the path is with the command echo $PATH, continuing with the them, the command is added to each of these directories separated by a colon as indicated on the image. Although I think I skipped something, Let's talk a bit about what shell is; The shell is an aplicattion which connects user inputs to kernel, in other words is an interpreter commands.

To dig a little deeper into what happens when we type "ls -l *.c", we will make a list of the steps to make it more detailed and graphic:

STEP 1, Using getline function, the program read and store the input line.

STEP 2, Separate lines using strtok function and stotre into the array by positions.

To be continue...


要查看或添加评论,请登录

Jarold Hakins的更多文章

  • Dynamic Libraries in C

    Dynamic Libraries in C

    Dynamic libraries are a set of classes, functions and procedures that are generally called methods that we can use them…

  • PROGRAMING LANGUAGE C#. "STATIC LIBRARIES"

    PROGRAMING LANGUAGE C#. "STATIC LIBRARIES"

    A static library is basically a set of object files (binary code), Which is integrated into a simple file. This file is…

社区洞察

其他会员也浏览了