<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Kelvin Wahome</title>
    <description>The latest articles on Forem by Kelvin Wahome (@wahomethegeek).</description>
    <link>https://forem.com/wahomethegeek</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F914119%2Fc1e353bd-0699-48db-adb7-77f74d1fae97.png</url>
      <title>Forem: Kelvin Wahome</title>
      <link>https://forem.com/wahomethegeek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/wahomethegeek"/>
    <language>en</language>
    <item>
      <title>MySQL won't start because of AppArmor</title>
      <dc:creator>Kelvin Wahome</dc:creator>
      <pubDate>Tue, 17 Sep 2024 12:14:19 +0000</pubDate>
      <link>https://forem.com/wahomethegeek/mysql-wont-start-because-of-apparmor-3kna</link>
      <guid>https://forem.com/wahomethegeek/mysql-wont-start-because-of-apparmor-3kna</guid>
      <description>&lt;p&gt;&lt;strong&gt;AppArmor&lt;/strong&gt; is a Linux security module that provides mandatory access control (MAC) for programs. It works by enforcing security policies that restrict how applications interact with the system, helping to protect against potential vulnerabilities and malicious behavior. Each application is assigned a security profile that specifies which files, network resources, and other system resources it can access.&lt;/p&gt;

&lt;p&gt;MySQL Workbench when installed as a Snap package on Ubuntu, it operates under the confinement of AppArmor. This confinement can sometimes block necessary services and interactions, leading to issues such as inability to connect to MySQL or errors related to authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Connect Required Snap Interfaces&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Snap applications, like MySQL Workbench, operate within a confined environment and often require additional permissions to function correctly. To resolve access issues, you may need to connect specific Snap interfaces. Open your terminal and run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;snap connect mysql-workbench-community:password-manager-service
snap connect mysql-workbench-community:ssh-keys
snap connect mysql-workbench-community:cups-control

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands grant MySQL Workbench the necessary permissions to interact with services such as password management, SSH keys, and printing controls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By connecting the necessary Snap interfaces you can resolve common access issues with MySQL Workbench on Ubuntu. These steps should help you restore full functionality and ensure smooth operation of your database management tasks.&lt;/p&gt;

&lt;p&gt;If you encounter further issues or have additional questions, feel free to leave a comment or reach out for support.&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>linux</category>
    </item>
    <item>
      <title>Building Your Own Shell in C: A Journey into Command-Line Magic</title>
      <dc:creator>Kelvin Wahome</dc:creator>
      <pubDate>Sat, 29 Jul 2023 20:20:14 +0000</pubDate>
      <link>https://forem.com/wahomethegeek/building-your-own-shell-in-c-a-journey-into-command-line-magic-2lon</link>
      <guid>https://forem.com/wahomethegeek/building-your-own-shell-in-c-a-journey-into-command-line-magic-2lon</guid>
      <description>&lt;p&gt;Today, I want to take you on an exciting journey into the world of command-line magic by creating your very own shell in the C programming language. Shells are an integral part of any operating system, allowing users to interact with the system using text commands. By building a simple shell from scratch, you'll gain a deeper understanding of how shells work and how they execute commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lets Get in it
&lt;/h2&gt;

&lt;p&gt;How does shell works? &lt;br&gt;
A shell reads user input, interprets the commands, and executes them by forking child processes. The standard C library provides functions like fork(), exec(), and wait() that help us achieve this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
#include &amp;lt;sys/wait.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#define MAX_INPUT_LENGTH 100

int main() {
    char input[MAX_INPUT_LENGTH];
    char* args[MAX_INPUT_LENGTH];
    int status;

    while (1) {
        printf("YourShell$ ");
        fgets(input, sizeof(input), stdin);

        /*Tokenize the input*/
        char* token = strtok(input, " \n");
        int i = 0;
        while (token != NULL) {
            args[i] = token;
            token = strtok(NULL, " \n");
            i++;
        }
        args[i] = NULL; /*Null-terminate the argument list*/

        if (strcmp(args[0], "exit") == 0) {
            printf("Exiting the shell...\n");
            break;
        }

        pid_t pid = fork();
        if (pid &amp;lt; 0) {
            perror("Fork error");
        } else if (pid == 0) {
            /*Child process*/
            if (execvp(args[0], args) == -1) {
                perror("Execution error");
                exit(EXIT_FAILURE);
            }
        } else {
            /*Parent process*/
            wait(&amp;amp;status);
        }
    }

    return 0;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How does this work
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The program sets up a loop to keep the shell running until the user types "exit."&lt;/li&gt;
&lt;li&gt;It prompts the user for input and reads the command from the standard input using fgets().&lt;/li&gt;
&lt;li&gt;The input is then tokenized into arguments using strtok() and stored in the args array.&lt;/li&gt;
&lt;li&gt;The shell checks if the command is "exit"; if so, it exits the loop.&lt;/li&gt;
&lt;li&gt;If not, it forks a child process using fork().&lt;/li&gt;
&lt;li&gt;In the child process, the command is executed using execvp(), which searches for the command in the system's PATH and runs it.&lt;/li&gt;
&lt;li&gt;The parent process waits for the child to complete using wait().&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Let's do it!!
&lt;/h2&gt;

&lt;h3&gt;
  
  
  To compile it we use gcc
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcc simple_shell.c -o myshell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Now we can execute this by :
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./myshell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;That's it. That's how shell works. Is it not interesting how the command line works?😃&lt;br&gt;
Of course, there's a lot more you can add to make it more feature-rich and robust, but this serves as an excellent starting point to dive deeper into the world of shells and command-line interfaces.&lt;/p&gt;

&lt;p&gt;If you have any questions or want to share your experiences, drop a comment below. I'd love to hear your thoughts!&lt;/p&gt;

&lt;p&gt;Stay curious, keep coding, and until next time, happy hacking! 🚀&lt;/p&gt;

&lt;p&gt;Big Thanks to ALX SE for introducing me to this fascinating world.&lt;/p&gt;

</description>
      <category>c</category>
      <category>developer</category>
      <category>shell</category>
    </item>
  </channel>
</rss>
