<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Samuel A. Florez on Medium]]></title>
        <description><![CDATA[Stories by Samuel A. Florez on Medium]]></description>
        <link>https://medium.com/@muxanz?source=rss-b5ea3413cc66------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KdRG9prM1JU_cs--2OYKLA.jpeg</url>
            <title>Stories by Samuel A. Florez on Medium</title>
            <link>https://medium.com/@muxanz?source=rss-b5ea3413cc66------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:28:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muxanz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How the shell works internally when entering a command]]></title>
            <link>https://medium.com/@muxanz/how-the-shell-works-internally-when-entering-a-command-42f08458870?source=rss-b5ea3413cc66------2</link>
            <guid isPermaLink="false">https://medium.com/p/42f08458870</guid>
            <category><![CDATA[commands]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Samuel A. Florez]]></dc:creator>
            <pubDate>Mon, 15 Apr 2019 06:28:03 GMT</pubDate>
            <atom:updated>2019-04-15T06:32:06.999Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hK3G4SkTqcunzmQVaAe_8g.png" /><figcaption>https://cdn.apptension.com/</figcaption></figure><p>Before explaining the topic mentioned in the title, I will briefly explain what a shell is. In general terms, a shell corresponds in the computer world to a command interpreter where the user has an available interface (CLI, Command-Line Interface), through which he has the possibility of accessing services of the operating system as well as executing or invoking programs. The term of shell comes from the use of consoles under the UNIX operating system in the 70’s, where they were connected to the central computer and started to work there. With the rise of GNU / Linux distributions, users have several shells available and among the most pupils are: sh, bash, etc.</p><p>With the above we are already in context to continue, as users must initially run our terminal, which will show us something similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*oBMpdlNi822Yvcia_bVlpA.png" /></figure><p>In the screenshot above, what is going on is that the shell is ready and waiting to receive a command after the $. This process is known as a wait for a command in the standard input, entered from the computer keyboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*0kvcpHUP7slZJPRHDJCs1g.png" /></figure><p>Once the command is typed, which for this particular case I will explain with “ls -l”, this must be followed with an ENTER, where the shell takes the line and saves it in a array of characters, together with the null character at the end “\ 0”, which indicates the end of the entered text.</p><p>This is a way in which the shell saves the above in memory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*B3V2v3DYS9KSsVRtJieMLw.png" /></figure><p>When the shell has saved the array, the next step it performs is to separate into strings of characters, using the “space” as the delimiter, through the tokenization process, thus remaining in the memory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*_XqNAFEElS_5R20wv6Kwjg.png" /></figure><p>Once the previous step has been completed, the shell continues with its work to verify if the received command matches a function call corresponding to the first word (<strong>ls “\ 0”</strong>, calling command), along with its predecessor, which would be the arguments (<strong>-l “\ 0”</strong>, argument to calling command) for the call command.</p><p>Then the shell will continue locating the corresponding function call, where it will try to match the first string of the command with some file located in the PATH environment variable, which corresponds to a list of directory locations separated by “:”, which are hosted in the system, and where the shell will search until you find the command (ls).</p><p>One way to show this variable is with the “echo $ PATH” command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*NKlniZ74ay3-0uY9R69Uaw.png" /></figure><p>After the shell has searched the paths of the mentioned directories, it finally locates the executable “ls” in the / bin directory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*9psU-obkDFtVxOolXdKeqA.png" /></figure><p>When the shell has managed to match the program to be executed, inside the memory it replaces the first string with the path to the directory that hosts “ls”, being as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*e05r46ZNv122bcwJESt6dA.png" /></figure><p>Taking into account what has been said previously, it is assumed that the command works without any difficulty, but how is the internal functioning in the system really?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*CyXm8QjZi7rdBENNj5A6PA.png" /><figcaption><a href="https://encrypted-tbn0.gstatic.com/">https://encrypted-tbn0.gstatic.com/</a></figcaption></figure><p>To answer this question it is necessary to understand that in Linux there are two elements that are the files and the processes. For our case the entered command “ls” is a file, that when it is executed, the system creates a process corresponding to an instance of a running program and that has an ID or PID, which is not more than a unique number, used by several functions or system calls (syscalls) to manipulate these processes.</p><p>When I refer to the system call, this means that it is a mechanism by which an application requests a service to the operating system and of which we will comment later.</p><p>Once the shell executes the command previously entered by the user, this is done by making a system call (syscall) to create a new process, but we must bear in mind that if the shell is already a process itself, the new process will be created within the shell process. This is called the parents and children process. Child processes are secondary because they are created from the main shell process.</p><p>To better understand this theory, let’s start by analyzing what happens since the shell starts, at this point a parent process is created that will remain active until the shell is closed with any PID:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhQZsjhVBkhtJdqfJEywPA.jpeg" /></figure><p>Once you have entered the command “ls -l” and the shell has already validated the PATH and is ready to run from / bin / ls, it creates a new process using a syscall fork ( ), this is where the child process appears.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6s0qrBoL0PeDhfa6ldNjZw.jpeg" /></figure><p>After the child process is created, it is where you can execute the entire entered command / bin / ls -l. To achieve this task you must make another syscall execve(), which is responsible for receiving as parameters the command / bin / ls and its flag -l, which will be executed in the child process, confirming the success of the execution with another syscall exit(), with a value of zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7zG_XWkG_Fpe4GQVrIHuew.jpeg" /></figure><p>When executing the execve () is finished, the child process will be terminated with another syscall wait (), which is responsible for the successful completion of the child process before returning to the parent process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pFq5kssnl__0bd9PQuwDDQ.jpeg" /></figure><p>Finally with all the above the command “ls -l” is executed in question of milliseconds, without the user being aware of what happens inside the system, with the following result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*AVjBSMb8RDkG7u-gVxf82A.png" /></figure><p>Following the previous result, the shell will again be waiting for a new command to be entered to execute:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*lSrj7NxUe-TuIj5qNW0bgw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42f08458870" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens when you use the gcc main.c ?]]></title>
            <link>https://medium.com/@muxanz/what-happens-when-you-use-the-gcc-main-c-a6fb091ac166?source=rss-b5ea3413cc66------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6fb091ac166</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c-language]]></category>
            <category><![CDATA[gcc]]></category>
            <dc:creator><![CDATA[Samuel A. Florez]]></dc:creator>
            <pubDate>Tue, 12 Feb 2019 02:44:14 GMT</pubDate>
            <atom:updated>2019-02-12T02:44:14.372Z</atom:updated>
            <content:encoded><![CDATA[<h3>What happens when you use the gcc main.c ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*xeTH3A8e6mmZchWO5TyfZA.png" /><figcaption>C language (<a href="https://postparaprogramadores.com/">https://postparaprogramadores.com</a>)</figcaption></figure><p>When we use the gcc in the command line to compile a program in C language, internally several processes are being carried out to take our source code files to binary or executable files.</p><p>To understand this more in detail I will carry out a series of steps.</p><ol><li>First we will create a main.c file, using the Emacs editor.</li></ol><pre>emacs main.c</pre><p>2. We add the following basic code, a typical hello world !.</p><pre>#include &lt;stdio.h&gt;</pre><pre>int main()<br>{<br>    printf(&quot;Hello World&quot;);</pre><pre>return 0;<br>}</pre><p>3. To achieve a simple compilation in GNU / Linux systems, it would be the following:</p><pre>gcc main.c -o main</pre><p>This generates us a binary file called main.</p><pre>main: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked</pre><p>The above indicates that the main file is output and type ELF, which is the equivalent of an .exe file in Windows.</p><p><strong>Compiling step by step</strong></p><p>In this section we will analyze what is done internally by the C language compiler, join me …</p><p><strong>Preprocessing</strong></p><p>Here the first thing the compiler does is to preprocess the source file (main.c), which means that it will interpret all the directives as #include, #define, among others and also the comments that we have written.</p><p>To preprocess our example, we execute the following line:</p><pre>gcc -E main.c -o main.i</pre><p>With the modifier -E, we specify to the compiler that only preprocesses, and that its output is written in the main.i file, extension used for preprocessed files. Now the main.i, has a content similar to this:</p><pre>extern int pclose (FILE *__stream);</pre><pre>extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));</pre><pre># 913 &quot;/usr/include/stdio.h&quot; 3 4</pre><pre>extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));</pre><pre>extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;</pre><pre>extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));</pre><pre># 943 &quot;/usr/include/stdio.h&quot; 3 4</pre><pre># 2 &quot;main.c&quot; 2</pre><pre>int main()</pre><pre>{</pre><pre>printf(&quot;Hello World&quot;);</pre><pre>return 0;</pre><pre>}</pre><p><strong>Compilation</strong></p><p>This corresponds to the next step of the process in which a binary code is obtained that is not executable, called object code, with the extension .o.</p><p>It is executed with the following line of code:</p><pre>gcc -C main.i -o main.o</pre><pre>main: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked</pre><p>With the above, we observed that an ELF file has been created.</p><p><strong>Link</strong></p><p>This step is achieved that the file of object code (main.o), becomes executable with the link to the libraries of the system, for this case will be all the functions of the header stdio.h, belonging to the standard library of C.</p><p>We can create our library file in the following way:</p><pre>ar -cvr main.a main.o</pre><p>The .a file is a static link library, different from the dynamic link libraries, which in GNU / Linux systems are called .so “Shared Object” and equivalent to the Windows .dll.</p><p>Now just enough to execute the following line of code, to achieve the link:</p><pre>gcc -Wall main.o -L/tmp/ -l main -o file_ex</pre><p>At this point, the main.o file has been linked to the main.a library and we have generated a new file file_ex.<br>-L indicates the path where the compiler searches for the libraries and -l indicates the particular library that we want to link to the object.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6fb091ac166" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What are and what serve hard and symbolic links in linux]]></title>
            <link>https://medium.com/@muxanz/what-are-and-what-serve-hard-and-symbolic-links-in-linux-8c700256c9a5?source=rss-b5ea3413cc66------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c700256c9a5</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[vagrant]]></category>
            <category><![CDATA[command-line]]></category>
            <dc:creator><![CDATA[Samuel A. Florez]]></dc:creator>
            <pubDate>Wed, 06 Feb 2019 04:46:22 GMT</pubDate>
            <atom:updated>2019-02-06T04:46:22.128Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*dFzQUEfUq8lk3tYJ8k8mOA.png" /><figcaption>direct access (<a href="https://www.softzone.es/">https://www.softzone.es</a>)</figcaption></figure><p>It is usual that people who are initiated in the world of Linux and who worked in Windows, always want to create shortcuts to their archives or folders of daily use.</p><p>In linux these shortcuts are known as hard links and symbolic links.</p><p>In the case of hard links, in linux the files and folders are assigned an integer number known as inode which in turn is housed in a specific space of the hard disk, which the hard link and the file share the same inode.</p><p>To create a hard link you must follow the following steps:</p><ol><li>We create a file with the following command:</li></ol><pre>touch file.txt</pre><p>2. Once the file has been created, we will consult its inode number by executing the following command:</p><pre>ls -li file.txt</pre><p>And this is the result:</p><pre>139687 -rw-rw-r-- 1 vagrant vagrant 0 Feb  6 03:42 file.txt</pre><p>This indicates that the inode of the file that has been created is 139687 and also has (1) an input file that points to the same inode.</p><p>3. The next step is to create the hard link in the following way:</p><pre>ln file.txt link_file</pre><p><strong>ln:</strong> command responsible for making links between files.<br><strong>file.txt:</strong> it is the original file or path that you have.<br><strong>link_file:</strong> is the name of the hard link.</p><p>4. We execute the following command again:</p><pre>ls -li file.txt</pre><pre>139687 -rw-rw-r-- 2 vagrant vagrant 0 Feb  6 03:42 file.txt</pre><p>It can be seen that the file has not changed its inode, but now it has two input files, which indicates that they are pointing to the same inode and therefore to the same information.</p><p>To create a symbolic link, the following steps should be followed:</p><ol><li>We create a file with the following command:</li></ol><pre>touch other_file.txt</pre><p>2. Once the file has been created, we will consult its inode number by executing the following command:</p><pre>ls -li other_file.txt</pre><p>And this is the result:</p><pre>139689 -rw-rw-r-- 1 vagrant vagrant 0 Feb  6 04:21 other_file.txt</pre><p>This indicates that the inode of the file that has been created is 139687 and also has (1) an input file that points to the same inode.</p><p>3. The next step is to create the hard link in the following way:</p><pre>ln -s vagrant/other_file.txt link_other_file</pre><p><strong>ln:</strong> command responsible for making links between files.<br><strong>-s:</strong> is the part of the command that indicates that the type of link that we are going to create is a symbolic link.<br><strong>vagrant / other_file.txt:</strong> it is the original file or path that you have.<br><strong>link_other_file:</strong> name of the route or link to create</p><p>4. Finally we execute the following command:</p><pre>ls -li</pre><pre>58351 lrwxrwxrwx 1 root root 22 Feb 6 04:33 link_other_file -&gt; vagrant/other_file.txt</pre><p>The result of this is that the symbolic link has a different inode (58351) to the original file, which indicates that it is not pointing to the same content but to the name of the original file.</p><p>In conclusion it can be determined that the difference between a hard link and symbolic is that if for a given case we want to eliminate the symbolic link by not sharing the same inode, the information of the original file is not deleted, otherwise it happens with the hard link that if he completely misses the information of the original file, because it shares the same inode.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c700256c9a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with the command ls]]></title>
            <link>https://medium.com/@muxanz/working-with-the-command-ls-f2a30ea7eba3?source=rss-b5ea3413cc66------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2a30ea7eba3</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[command-line]]></category>
            <dc:creator><![CDATA[Samuel A. Florez]]></dc:creator>
            <pubDate>Tue, 05 Feb 2019 03:46:17 GMT</pubDate>
            <atom:updated>2019-02-05T03:52:03.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*H3X2pm4gIj0exXa9T9b1JA.png" /><figcaption>Command line (linoxide.com)</figcaption></figure><p>When working with the linux command line, it is very common to use the ls command. This command means list, allowing you to list the file and directories of the working directory or of a specific directory.</p><p>For example if we are located on a directory that has several files with different extensions, of which we only need to list those with the extension .c (A .C file can include the complete source code written in C or C ++.), Next command to type the: ls * .c.</p><p>As indicated previously, ls will list the files afbetically, the sign * is an indicative that shows all the elements and finally .c refers to the files that end with that extension.</p><p>It should be noted that the ls command has several very useful options to view the listed files or directories.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2a30ea7eba3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>