<?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>DEV Community: Oni Toluwalope</title>
    <description>The latest articles on DEV Community by Oni Toluwalope (@toluwanee).</description>
    <link>https://dev.to/toluwanee</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%2F1723272%2Fc8525cea-2002-48fb-a067-4c23fe41b145.jpg</url>
      <title>DEV Community: Oni Toluwalope</title>
      <link>https://dev.to/toluwanee</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/toluwanee"/>
    <language>en</language>
    <item>
      <title>HOW A 30-MINUTE TASK TURNED INTO A 9-HOUR TROUBLESHOOTING NIGHTMARE</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Tue, 12 Aug 2025 17:17:33 +0000</pubDate>
      <link>https://dev.to/toluwanee/how-a-30-minute-task-turned-into-a-9-hour-troubleshooting-nightmare-55bb</link>
      <guid>https://dev.to/toluwanee/how-a-30-minute-task-turned-into-a-9-hour-troubleshooting-nightmare-55bb</guid>
      <description>&lt;p&gt;As developers, and engineers, we all have those "quick tasks" we expect to knock out in half an hour, tops. A few weeks back, my goal was simple: set up &lt;strong&gt;SonarQube&lt;/strong&gt; locally to get a better understanding of its configuration. While I'd used it before on some IBM cloud machines, I wanted hands-on experience with a local setup.&lt;/p&gt;

&lt;p&gt;I'd made a few minor code changes and wanted to see how SonarQube would flag them—a process I anticipated would take around 30 minutes from start to finish. Little did I know, this seemingly straightforward task would plunge me into a rabbit hole of configuration errors and resource limitations, stretching my troubleshooting skills to their limit over a grueling nine hours.&lt;/p&gt;

&lt;p&gt;The first sign of trouble appeared quickly. SonarQube simply refused to start. When I tried to access it through my browser, all I got was a &lt;strong&gt;&lt;code&gt;connection refused&lt;/code&gt;&lt;/strong&gt; error. My initial reaction was slight annoyance, but nothing alarming. "Probably just a small hiccup," I thought, diving into what I assumed would be a quick configuration tweak.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;My First Mistake: I Didn't Check the Logs Immediately&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Instead of checking the logs, I started fiddling with network settings, assuming the issue was a port conflict or a firewall rule. I spent a good hour going down this path, tweaking configurations that ultimately had nothing to do with the actual problem. Had I taken a moment to peek at the SonarQube logs right away, I would have seen a clear error message screaming about &lt;strong&gt;insufficient memory map areas&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Eventually, after my fruitless network explorations, I investigated the console output more closely. That's where I was greeted by a cryptic error message mentioning &lt;strong&gt;&lt;code&gt;vm.max_map_count&lt;/code&gt;&lt;/strong&gt;. This was a parameter I'd vaguely encountered before, but its exact purpose eluded me.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;My Second Mistake: I Misinterpreted What &lt;code&gt;vm.max_map_count&lt;/code&gt; Meant&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This leads to my second blunder: I initially thought &lt;code&gt;vm.max_map_count&lt;/code&gt; was directly related to the total memory available to my Kali Linux Virtual Machine. I misinterpreted the "vm" as "Virtual Machine" rather than "virtual memory." Based on this flawed understanding, I started adjusting the RAM size of my virtual machine in Oracle VirtualBox, thinking I needed to allocate more memory. This, of course, didn't solve the issue, and I spent another couple of hours chasing this red herring 😭😭😭😭😭.&lt;/p&gt;

&lt;p&gt;It wasn't until I decided to research the error message more thoroughly that the moment of discovery came. I learned that this kernel parameter defines the maximum number of memory map areas a process can have. SonarQube, specifically its Elasticsearch component, requires a large number of these maps, and the default setting on my system was simply too low.&lt;/p&gt;

&lt;p&gt;Even with this newfound understanding, I still hesitated. Modifying kernel parameters felt like venturing into the operating system's core, and I wanted to be sure I was making the right change. So, I spent some more time double-checking the documentation and searching for similar issues online.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;My Third Mistake: I Didn't Increase &lt;code&gt;vm.max_map_count&lt;/code&gt; Sooner&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This was my third mistake: not increasing &lt;code&gt;vm.max_map_count&lt;/code&gt; in a timely manner. While due diligence is important, my hesitation prolonged the outage unnecessarily.&lt;/p&gt;

&lt;p&gt;Finally, I bit the bullet and decided to increase the &lt;code&gt;vm.max_map_count&lt;/code&gt; value. I used the command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo sysctl -w vm.max_map_count=524288&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(You can also edit the &lt;code&gt;sysctl.conf&lt;/code&gt; file, add the line &lt;code&gt;vm.max_map_count=524288&lt;/code&gt;, and apply the changes using &lt;code&gt;sudo sysctl -p&lt;/code&gt;.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I felt a surge of hope as I restarted SonarQube.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;My Fourth Mistake: I Overlooked Storage and Under-Allocated Resources&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;My elation was short-lived. SonarQube started, but it was incredibly slow and unstable, frequently crashing with out-of-memory errors. I wondered what was wrong since I saw that &lt;strong&gt;512 MB&lt;/strong&gt; of memory was the minimum required for SonarQube to run, and I had set it to that value. Out of frustration, I ended up increasing the &lt;code&gt;vm.max_map_count&lt;/code&gt; to &lt;strong&gt;2,097,152 KB (2 GB)&lt;/strong&gt;, of which the initial &lt;code&gt;524,288&lt;/code&gt; was sufficient, but I was still faced with the same problems and, once again, did not read the logs on time.&lt;/p&gt;

&lt;p&gt;I tried different things I saw online regarding the out-of-memory error, and nothing worked. Eventually, checking the logs led me to another realization: &lt;strong&gt;I didn't have enough storage on my Kali Linux virtual machine&lt;/strong&gt;. The virtual disk was almost full, leaving insufficient space for SonarQube to operate efficiently, especially with Elasticsearch indexing and storing data.&lt;/p&gt;

&lt;p&gt;This was the final piece of the puzzle. I had to shut down the virtual machine, resize the virtual disk in my virtualization software, delete some unnecessary files, and then expand the filesystem within Kali Linux.&lt;/p&gt;

&lt;p&gt;After this final step, I restarted the entire system and, with bated breath, started SonarQube again. This time, it worked! The web interface loaded quickly, the code analysis ran smoothly, and my initial 30-minute task was finally completed—nine hours later, a significant portion of which was also spent waiting for my &lt;strong&gt;slow, and patient testing&lt;/strong&gt; computer to respond.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Key Takeaways from the Marathon Troubleshooting Session&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This experience, though frustrating, was a valuable reminder of several key lessons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check the Logs First:&lt;/strong&gt; They are your best friends. Don't overlook them in your initial attempts to diagnose a problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Understand Error Messages:&lt;/strong&gt; Don't make assumptions. Research cryptic error messages to grasp the underlying issue accurately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Address System Requirements:&lt;/strong&gt; Ensure your system meets the minimum and recommended requirements for the software you are running, including memory, storage, and kernel parameters. Don't assume default settings are sufficient.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be Decisive (But Informed):&lt;/strong&gt; While research is crucial, don't hesitate to implement a likely solution once you have a good understanding of the problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consider the Environment:&lt;/strong&gt; If you're working in a virtualized environment, remember to check the resources allocated to the virtual machine itself.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What was supposed to be a quick 30-minute code quality check turned into a nine-hour deep dive into system configuration and resource management. While I wouldn't wish this marathon troubleshooting session on anyone, the satisfaction of finally resolving the issue, coupled with the valuable lessons learned—like the pain of working under tight compute resources—made it (almost) worth the time.&lt;/p&gt;

&lt;p&gt;Now, if you'll excuse me, I need a hot bowl of chicken pepper soup!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Configuration Management: 12 factor, Factor III</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Thu, 03 Jul 2025 07:18:03 +0000</pubDate>
      <link>https://dev.to/toluwanee/configuration-management-12-factor-factor-iii-hoa</link>
      <guid>https://dev.to/toluwanee/configuration-management-12-factor-factor-iii-hoa</guid>
      <description>&lt;p&gt;As a developer or DevOps engineer, you're well aware of the importance of keeping your application secure and scalable. One crucial aspect of achieving this is by following the 12-Factor App methodology, specifically Factor III: Configuration. In this article, we'll dive into the world of configuration management, exploring its benefits, best practices, and the importance of prioritizing it in your development workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why Configuration Management Matters&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Configuration management is a critical component of application development, and its importance cannot be overstated. Here are three key reasons why configuration management matters:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Security&lt;/em&gt;&lt;/strong&gt;: By storing configuration in the environment, separate from code, you can prevent sensitive credentials like API keys and database passwords from being exposed in version control. This is especially important in today's world, where security breaches can have devastating consequences.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Portability&lt;/em&gt;&lt;/strong&gt;: With configuration management, you can deploy the same build artifact across different environments (dev, staging, production) by changing environment variables. This eliminates the need for code changes, making it easier to manage your application's lifecycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Flexibility&lt;/em&gt;&lt;/strong&gt;: Configuration management allows you to easily manage settings for different deployment stages or scaling scenarios. This flexibility is essential in today's fast-paced development environment, where applications need to be adaptable and responsive to changing requirements.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Best Practices&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, how can you implement effective configuration management in your application? Here are some best practices to get you started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Use &lt;code&gt;.env&lt;/code&gt; files for local development&lt;/em&gt;&lt;/strong&gt;: Keep sensitive data separate from your codebase by using &lt;code&gt;.env&lt;/code&gt; files for local development. This will help prevent accidental exposure of sensitive credentials.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Consider using a secrets management tool&lt;/em&gt;&lt;/strong&gt;: Tools like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault can help you manage sensitive data and configurations securely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;The Case for Alternative Secrets Management Tools&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While HashiCorp Vault Secrets is a powerful tool for secrets management, it's worth noting that HashiCorp will be discontinuing HCP Vault Secrets. After June 30, 2025, new customers won't be able to purchase it, and existing customers will have until August 27, 2025. This means it's essential to explore alternative solutions that can provide similar functionality.&lt;/p&gt;

&lt;p&gt;Some popular alternatives to HashiCorp Vault include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;AWS Secrets Manager&lt;/em&gt;&lt;/strong&gt;: A fully managed service that securely stores and manages sensitive data in AWS environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Azure Key Vault&lt;/em&gt;&lt;/strong&gt;: A cloud-based solution for safeguarding cryptographic keys and other secrets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Doppler&lt;/em&gt;&lt;/strong&gt;: A multi-cloud SecretOps Platform for enterprise-scale secrets management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Akeyless Vault&lt;/em&gt;&lt;/strong&gt;: A cloud-native, SaaS-first secrets management solution that eliminates traditional vault-based architectures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;em&gt;Make Configuration Management a Priority&lt;/em&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don't risk exposing sensitive credentials in your code. By prioritizing configuration management, you can ensure your application's security and scalability. Learn from common mistakes and adopt best practices to safeguard your secrets.&lt;/p&gt;

&lt;p&gt;In conclusion, configuration management is a critical aspect of application development that requires careful consideration. By following best practices and leveraging the right tools, you can ensure the security and scalability of your application. Make configuration management a priority today and take the first step towards building more secure and scalable applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Key Points&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prioritize configuration management to ensure application security and scalability.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;.env&lt;/code&gt; files for local development and consider secrets management tools for production environments.&lt;/li&gt;
&lt;li&gt;Explore alternative solutions to HashiCorp Vault, such as AWS Secrets Manager, Azure Key Vault, Doppler, and Akeyless Vault.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these best practices and leveraging the right tools, you can ensure the security and scalability of your application.&lt;/p&gt;

&lt;h1&gt;
  
  
  DevOps #12Factor #ConfigurationManagement #AppSec #SecurityBestPractices #EnvironmentVariables
&lt;/h1&gt;

</description>
      <category>devops</category>
      <category>12factor</category>
      <category>configurationmanagement</category>
      <category>appsec</category>
    </item>
    <item>
      <title>Dependency Management 101: Mastering the 12-Factor App's Factor II</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Wed, 14 May 2025 21:28:08 +0000</pubDate>
      <link>https://dev.to/toluwanee/dependency-management-101-mastering-the-12-factor-apps-factor-ii-54kf</link>
      <guid>https://dev.to/toluwanee/dependency-management-101-mastering-the-12-factor-apps-factor-ii-54kf</guid>
      <description>&lt;p&gt;&lt;em&gt;Tackling the Pain Points of Deployment Failures&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Who hasn't experienced the frustration of a deployment failure due to a missing library or the wrong version on the server? Factor II of the 12-Factor App addresses this issue head-on, and it's a game-changer for developers. In this article, we'll dive into the world of dependency management and explore the two crucial aspects that can make or break your application's reliability.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Power of Explicit Declaration&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Explicit declaration is the practice of listing every single dependency in a manifest file. This approach ensures that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Dependencies are clearly defined&lt;/em&gt;: No more wondering what's required for your application to run.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Versions are specified&lt;/em&gt;: Avoid version conflicts and ensure reproducibility.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Dependencies are easily manageable&lt;/em&gt;: Update, add, or remove dependencies with confidence.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some popular manifest files include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;requirements.txt&lt;/code&gt; for Python&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;go.mod&lt;/code&gt; for Go&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;package.json&lt;/code&gt; for Node.js&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;A Relatable Analogy&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Imagine you're preparing a meal (application) that requires specific ingredients (dependencies) like flour, sugar, and eggs. You write down all the ingredients you need and their quantities (versions) on a shopping list. Similarly, explicit declaration in dependency management involves listing all dependencies and their versions in a manifest file.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Importance of Isolation&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Isolation is crucial for maintaining a consistent and reliable environment. Tools like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python's &lt;code&gt;virtualenv&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Go modules&lt;/li&gt;
&lt;li&gt;Docker containers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;help keep dependencies separate from:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;System dependencies&lt;/em&gt;: Avoid polluting the system with project-specific dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Other projects&lt;/em&gt;: Prevent dependency conflicts between projects.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Building on the Analogy&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Just as you separate your items into different bags for each meal or occasion, isolation in dependency management achieves a similar goal. It keeps project-specific dependencies separate from system dependencies and other projects, ensuring that your application runs smoothly and consistently.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Benefits of Dependency Management&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The combination of explicit declaration and isolation dramatically reduces environment inconsistencies and makes deployments smoother. Although it may seem minor, neglecting dependency management can lead to significant time waste, and I've learned firsthand that it's essential for reliable software delivery.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Best Practices for Dependency Management&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To take your dependency management to the next level:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Use a dependency manager&lt;/em&gt;: Choose a tool that fits your project's needs, such as npm, yarn, or gradle.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Keep dependencies up-to-date&lt;/em&gt;: Regularly update dependencies to ensure security and stability.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Test dependencies&lt;/em&gt;: Verify that dependencies work as expected in your application.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;What Tools Do You Rely On?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Share your favorite dependency management tools and techniques in the comments below. Let's learn from each other and improve our dependency management skills.&lt;/p&gt;

&lt;p&gt;By mastering dependency management, you'll be well on your way to building reliable, scalable, and maintainable applications. Happy coding!&lt;/p&gt;

</description>
      <category>12factor</category>
      <category>devops</category>
      <category>softwaredevelopment</category>
      <category>dependency</category>
    </item>
    <item>
      <title>Decoding the Shebang (#!) in Shell Scripts: A Deep Dive</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Wed, 14 May 2025 21:20:39 +0000</pubDate>
      <link>https://dev.to/toluwanee/decoding-the-shebang-in-shell-scripts-a-deep-dive-n8d</link>
      <guid>https://dev.to/toluwanee/decoding-the-shebang-in-shell-scripts-a-deep-dive-n8d</guid>
      <description>&lt;p&gt;When working with shell scripts, you've likely encountered the mysterious &lt;code&gt;#!&lt;/code&gt; line at the top. But what does it do? In this post, we'll explore the Shebang, its purpose, and best practices for using it in your shell scripts.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is the Shebang?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Shebang, also known as Hashbang or "sha-bang", is a special sequence of characters (&lt;code&gt;#!&lt;/code&gt;) that specifies the interpreter to use when running a script directly. It's typically followed by the path to an interpreter, such as &lt;code&gt;/bin/bash&lt;/code&gt; or &lt;code&gt;/usr/bin/env bash&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How Does the Shebang Work?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When you run a script directly (e.g., &lt;code&gt;./my_script.sh&lt;/code&gt;), the operating system's program loader reads the Shebang line to determine which interpreter to use. The interpreter is then responsible for executing the commands within the script.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Types of Shebang&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#!/bin/bash&lt;/code&gt;: Specifies the Bash shell interpreter located at &lt;code&gt;/bin/bash&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#!/usr/bin/env bash&lt;/code&gt;: Searches for the Bash executable in the user's PATH, making the script more portable across systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Why Use &lt;code&gt;#!/usr/bin/env bash&lt;/code&gt;?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;#!/usr/bin/env bash&lt;/code&gt; provides better portability across systems where Bash might reside in a different location (like &lt;code&gt;/usr/local/bin/bash&lt;/code&gt;). This approach ensures your script works regardless of the Bash installation location.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Consequences of Forgetting the Shebang&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Without the Shebang, you'd need to specify the interpreter when running the script, like &lt;code&gt;bash sample_script.sh&lt;/code&gt;. This can be inconvenient, especially when working with complex scripts or automating tasks.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Best Practices&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;#!/usr/bin/env bash&lt;/code&gt; for better portability.&lt;/li&gt;
&lt;li&gt;Make your scripts executable with &lt;code&gt;chmod +x my_script.sh&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Run your scripts directly with &lt;code&gt;./my_script.sh&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*] &lt;/p&gt;

&lt;p&gt;By understanding the Shebang and using it effectively, you can write more efficient, portable, and convenient shell scripts.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Conclusion&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Shebang is a critical component of shell scripting, allowing you to specify the interpreter and make your scripts directly executable. By following best practices and using &lt;code&gt;#!/usr/bin/env bash&lt;/code&gt;, you can ensure your scripts work across different systems and environments.&lt;/p&gt;

&lt;h1&gt;
  
  
  ShellScripting #Bash #Linux #Unix #Programming #Automation #DevOps
&lt;/h1&gt;

</description>
    </item>
    <item>
      <title>Decoding the Shebang (#!) in Shell Scripts: A Deep Dive</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Thu, 08 May 2025 22:15:02 +0000</pubDate>
      <link>https://dev.to/toluwanee/decoding-the-shebang-in-shell-scripts-a-deep-dive-73l</link>
      <guid>https://dev.to/toluwanee/decoding-the-shebang-in-shell-scripts-a-deep-dive-73l</guid>
      <description>&lt;p&gt;When working with shell scripts, you've likely encountered the mysterious &lt;code&gt;#!&lt;/code&gt; line at the top. But what does it do? In this post, we'll explore the Shebang, its purpose, and best practices for using it in your shell scripts.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is the Shebang?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Shebang, also known as Hashbang or "sha-bang", is a special sequence of characters (&lt;code&gt;#!&lt;/code&gt;) that specifies the interpreter to use when running a script directly. It's typically followed by the path to an interpreter, such as &lt;code&gt;/bin/bash&lt;/code&gt; or &lt;code&gt;/usr/bin/env bash&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How Does the Shebang Work?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When you run a script directly (e.g., &lt;code&gt;./my_script.sh&lt;/code&gt;), the operating system's program loader reads the Shebang line to determine which interpreter to use. The interpreter is then responsible for executing the commands within the script.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Types of Shebang&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;#!/bin/bash&lt;/code&gt;: Specifies the Bash shell interpreter located at &lt;code&gt;/bin/bash&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#!/usr/bin/env bash&lt;/code&gt;: Searches for the Bash executable in the user's PATH, making the script more portable across systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Why Use &lt;code&gt;#!/usr/bin/env bash&lt;/code&gt;?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;#!/usr/bin/env bash&lt;/code&gt; provides better portability across systems where Bash might reside in a different location (like &lt;code&gt;/usr/local/bin/bash&lt;/code&gt;). This approach ensures your script works regardless of the Bash installation location.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Consequences of Forgetting the Shebang&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Without the Shebang, you'd need to specify the interpreter when running the script, like &lt;code&gt;bash sample_script.sh&lt;/code&gt;. This can be inconvenient, especially when working with complex scripts or automating tasks.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Best Practices&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;#!/usr/bin/env bash&lt;/code&gt; for better portability.&lt;/li&gt;
&lt;li&gt;Make your scripts executable with &lt;code&gt;chmod +x my_script.sh&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Run your scripts directly with &lt;code&gt;./my_script.sh&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/usr/bin/env bash

echo "Hello, World!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By understanding the Shebang and using it effectively, you can write more efficient, portable, and convenient shell scripts.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Conclusion&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Shebang is a critical component of shell scripting, allowing you to specify the interpreter and make your scripts directly executable. By following best practices and using &lt;code&gt;#!/usr/bin/env bash&lt;/code&gt;, you can ensure your scripts work across different systems and environments.&lt;/p&gt;

&lt;h1&gt;
  
  
  ShellScripting #Bash #Linux #Unix #Programming #Automation #DevOps
&lt;/h1&gt;

</description>
    </item>
    <item>
      <title>Foundation of Consistency: The 12-Factor App's 'Codebase' Principle</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Sun, 04 May 2025 22:18:19 +0000</pubDate>
      <link>https://dev.to/toluwanee/foundation-of-consistency-the-12-factor-apps-codebase-principle-3ci8</link>
      <guid>https://dev.to/toluwanee/foundation-of-consistency-the-12-factor-apps-codebase-principle-3ci8</guid>
      <description>&lt;p&gt;The 12-Factor App methodology provides a robust framework for building scalable and maintainable applications. The first factor, "Codebase," sets the foundation for a well-structured development process. In this post, we'll dive into the importance of maintaining one codebase per application, tracked in a version control system like Git.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let's define what a codebase is&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A codebase, also known as a code repository or source code repository, is a collection of source code files and related assets that make up a software application or system. At it's core, it is the entire body of code that defines the functionality, behavior, and structure of a software project.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why One Codebase Matters&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Having a single codebase per application ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Traceability&lt;/em&gt;: Every deploy originates from a specific, known commit hash, making it easier to track changes and debug issues.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Consistency&lt;/em&gt;: The same code forms the basis for all deployments, reducing environment-specific variations and ensuring that your application behaves consistently across development, testing, and production environments.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Collaboration&lt;/em&gt;: A single codebase provides a single source of truth for all developers, promoting collaboration and reducing confusion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;The Benefits of a Single Codebase&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;While you might have multiple instances or deploys of your application, they should all stem from this single, version-controlled codebase. This approach ensures that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All changes are tracked and auditable&lt;/li&gt;
&lt;li&gt;Deployments are consistent and predictable&lt;/li&gt;
&lt;li&gt;Developers can collaborate effectively&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Best Practices&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To implement this principle, follow these best practices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use a version control system like Git to track changes to your codebase&lt;/li&gt;
&lt;li&gt;Maintain a single codebase per application&lt;/li&gt;
&lt;li&gt;Ensure all deployments originate from the same codebase&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following the "Codebase" principle, you'll lay the foundation for a scalable, consistent, maintainable, and collaborative development process.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;#12factorapp #Codebase #VersionControl #Collaboration #Scalability&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mastering Git: Understanding `git init` and `git clone` for Effective Version Control</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Sun, 04 May 2025 21:59:34 +0000</pubDate>
      <link>https://dev.to/toluwanee/mastering-git-understanding-git-init-and-git-clone-for-effective-version-control-3k9l</link>
      <guid>https://dev.to/toluwanee/mastering-git-understanding-git-init-and-git-clone-for-effective-version-control-3k9l</guid>
      <description>&lt;p&gt;As a developer, you're likely no stranger to Git, the powerful version control system that helps you manage changes to your codebase. However, for those just starting out or looking to solidify their understanding, two fundamental commands can often cause confusion: &lt;code&gt;git init&lt;/code&gt; and &lt;code&gt;git clone&lt;/code&gt;. In this post, we'll dive into the differences between these commands, when to use each, and how they fit into your overall Git workflow.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;code&gt;git init&lt;/code&gt;: Starting a New Project from Scratch&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When you're beginning a new project and want to put it under version control, &lt;code&gt;git init&lt;/code&gt; is the command you'll use. This command creates a new Git repository in your project directory, initializing it with a hidden &lt;code&gt;.git&lt;/code&gt; folder that tracks changes to your code.&lt;/p&gt;

&lt;p&gt;Here's a step-by-step breakdown of what happens when you run &lt;code&gt;git init&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A new &lt;code&gt;.git&lt;/code&gt; directory is created in your project folder, containing the necessary metadata for Git to track changes.&lt;/li&gt;
&lt;li&gt;Your project is now under version control, and you can start committing changes.&lt;/li&gt;
&lt;li&gt;No connection to a remote repository is made automatically. You'll need to add this manually using &lt;code&gt;git remote add origin &amp;lt;URL&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;code&gt;git clone &amp;lt;repository URL&amp;gt;&lt;/code&gt;: Getting a Local Copy of an Existing Project&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On the other hand, when you want to obtain a local copy of a project that already exists on a remote server (like GitHub, GitLab, or Bitbucket), &lt;code&gt;git clone&lt;/code&gt; is the way to go. This command downloads the entire project history and sets up a connection to the remote repository, allowing you to start working on the project locally.&lt;/p&gt;

&lt;p&gt;Here's what happens when you run &lt;code&gt;git clone &amp;lt;repository URL&amp;gt;&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The entire project history is downloaded to your local machine, including all commits, branches, and tags.&lt;/li&gt;
&lt;li&gt;A connection to the remote repository is established, allowing you to push and pull changes.&lt;/li&gt;
&lt;li&gt;The remote repository is automatically set up as the &lt;code&gt;origin&lt;/code&gt; remote, making it easy to collaborate with others.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;When to Use Each Command&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, when should you use &lt;code&gt;git init&lt;/code&gt; versus &lt;code&gt;git clone&lt;/code&gt;? Here are some scenarios to help you decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;git init&lt;/code&gt; when:

&lt;ul&gt;
&lt;li&gt;You're starting a new project from scratch and want to put it under version control.&lt;/li&gt;
&lt;li&gt;You want to create a new repository without connecting to a remote server.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Use &lt;code&gt;git clone&lt;/code&gt; when:

&lt;ul&gt;
&lt;li&gt;You want to obtain a local copy of an existing project from a remote server.&lt;/li&gt;
&lt;li&gt;You're collaborating with others on a project and need to get the latest changes.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Best Practices for Working with Git&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that you understand the difference between &lt;code&gt;git init&lt;/code&gt; and &lt;code&gt;git clone&lt;/code&gt;, here are some best practices to keep in mind when working with Git:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always initialize your project with &lt;code&gt;git init&lt;/code&gt; or &lt;code&gt;git clone&lt;/code&gt; to track changes and collaborate with others.&lt;/li&gt;
&lt;li&gt;Use meaningful commit messages to describe the changes you've made.&lt;/li&gt;
&lt;li&gt;Regularly push your changes to a remote repository to ensure your work is backed up and accessible to others.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By mastering &lt;code&gt;git init&lt;/code&gt; and &lt;code&gt;git clone&lt;/code&gt;, you'll be well on your way to becoming a Git pro and managing your projects effectively. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Additional Resources&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git documentation: &lt;a href="https://git-scm.com/docs/git-init" rel="noopener noreferrer"&gt;https://git-scm.com/docs/git-init&lt;/a&gt;, &lt;a href="https://git-scm.com/docs/git-clone" rel="noopener noreferrer"&gt;https://git-scm.com/docs/git-clone&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;GitHub guides: &lt;a href="https://guides.github.com/introduction/git-handbook/" rel="noopener noreferrer"&gt;https://guides.github.com/introduction/git-handbook/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Brief Intro to Operating Systems for Devops</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Tue, 31 Dec 2024 13:13:50 +0000</pubDate>
      <link>https://dev.to/toluwanee/brief-intro-to-operating-systems-2eoa</link>
      <guid>https://dev.to/toluwanee/brief-intro-to-operating-systems-2eoa</guid>
      <description>&lt;p&gt;An operating system provides a base for application software and act as an intermediary between the hardware, applications and the human user.&lt;/p&gt;

&lt;p&gt;Some examples of operating systems used in modern day(2024): Android - developed by, iOS, MacOS, Windows, and Linux.&lt;/p&gt;

&lt;p&gt;To understand what an Operating System does we need to understand the basic structure of a computer.&lt;/p&gt;

&lt;p&gt;From bottom up, the computer consist of:&lt;/p&gt;

&lt;p&gt;| Human user | - You&lt;br&gt;
| Application Software | - Web browser, Word processors, Games&lt;br&gt;
| Operating Systems /System Software | - iOS, Linux, Windows...&lt;br&gt;
| Hardware | - CPU, Memory, Input Output devices&lt;/p&gt;

&lt;p&gt;Hardware: Resources like CPU, Memory: RAM and ROM, Motherboard, Input-Output devices: Mouse, display, keyboard.&lt;/p&gt;

&lt;p&gt;Application Softwares:  They are softwares that are used to perfom specific tasks eg.  Web browser, Word processors, Games&lt;/p&gt;

&lt;p&gt;Imagine a world without OS where the user is to use the application software to interact with the computer hardware, &lt;br&gt;
 the user will have to tell the computer what to do in a step by step fashion using code.&lt;br&gt;
For example the user wants to use a web browser called firefox, &lt;br&gt;
the user will tell the hardware to load firefox to memory, &lt;br&gt;
after loading it,&lt;br&gt;
tell it to prepare the application to receive input,&lt;br&gt;
display each character that is being typed on the monitor,&lt;br&gt;
after displaying all characters, after displaying all characters, &lt;br&gt;
you tell it you are done typing, &lt;br&gt;
then you tell it again to convert it to packets, &lt;br&gt;
after the data is being split into packet,&lt;br&gt;&lt;br&gt;
the user will request that the hardware open up the network ports, &lt;br&gt;
then tell it to allow data outflow . . . &lt;/p&gt;

&lt;p&gt;So, without the OS you have to manually dictate every step of what to do in form of code, and it will be very difficult to work with the computer if there is no operating system.  And so this is the ease operating system brings.&lt;/p&gt;

&lt;p&gt;If an Operating system was available all the user will do is to click on the program then type the address on the address bar then click enter, and the operating system takes the job of telling the hardware the step by step process on what to do. This makes the computer easier to use&lt;/p&gt;

&lt;p&gt;So now it is safe to say &lt;strong&gt;an operating system manages computer hardware, provides a base for application software and act as an intermediary between the hardware, applications and the human user.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Main Functions of an operating system
&lt;/h3&gt;

&lt;p&gt;Process management/ Task scheduling:&lt;br&gt;
Memory Management: Handles running applications (processes), multitasking, and scheduling.&lt;br&gt;
File System Management: Organizes and controls data storage and access&lt;br&gt;
Input/Output management: Input/Output connection and flow&lt;/p&gt;

&lt;h2&gt;
  
  
  Other functions
&lt;/h2&gt;

&lt;p&gt;Security management&lt;br&gt;
Network management&lt;br&gt;
Interfaces between hardware and software&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Operating Systems
&lt;/h3&gt;

&lt;p&gt;Batch OS&lt;br&gt;
Real Time OS (RTOS)&lt;br&gt;
Time Sharing OS&lt;br&gt;
Distributed OS&lt;br&gt;
Network OS&lt;/p&gt;

&lt;h3&gt;
  
  
  Goals of an operating system
&lt;/h3&gt;

&lt;p&gt;Ease of use&lt;br&gt;
Allocation of resources&lt;br&gt;
Efficiency  &lt;/p&gt;

&lt;h3&gt;
  
  
  Why Operating Systems Matter in DevOps
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Hosting Applications&lt;br&gt;
Every application needs an OS to run. DevOps professionals often work with servers running Linux or Windows to host web applications, databases, and other services.&lt;br&gt;
Linux is preferred for its stability, open-source nature, and extensive toolset. Windows Server is also common in enterprise environments requiring compatibility with Microsoft tools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Containerization and Virtualization&lt;br&gt;
Containers (e.g., Docker) and virtual machines (e.g., VMware, VirtualBox) rely heavily on OS-level features for isolation and resource management. Tools like Kubernetes orchestrate these containers, making OS knowledge indispensable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automation and Scripting&lt;br&gt;
Automation in DevOps involves writing scripts and using configuration management tools. These often interact directly with the OS to:&lt;br&gt;
Manage system users and permissions&lt;br&gt;
Install software packages&lt;br&gt;
Configure network settings&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitoring and Troubleshooting&lt;br&gt;
Understanding the OS helps in monitoring performance and diagnosing issues using tools like:&lt;br&gt;
Linux: top, htop, dstat, journalctl&lt;br&gt;
Windows: Task Manager, Event Viewer, PowerShell&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Some Key Operating System Concepts for DevOps
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Processes and Services&lt;br&gt;
Processes: Running applications or tasks. Use tools like ps (Linux) or Task Manager (Windows) to monitor them.&lt;br&gt;
Services: Background processes that perform specific functions, e.g., web servers (Nginx, Apache), loggers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;File Systems&lt;br&gt;
Linux: Follows a hierarchical structure with directories like /home, /var, /etc.&lt;br&gt;
Windows: Follows a flat directory structure that uses drive letters (e.g., C:) and organizes files accordingly.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Learn commands like ls, cd, cp, rm (Linux) or PowerShell equivalents for file management.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Networking&lt;br&gt;
Operating systems manage network interfaces and routing. Key tasks include:&lt;br&gt;
Configuring IP addresses&lt;br&gt;
Managing firewalls (e.g., iptables, Windows Defender Firewall)&lt;br&gt;
Troubleshooting with tools like ping, netstat, traceroute&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User Management and Permissions&lt;br&gt;
Linux: Uses file permission systems (chmod, chown) and role-based access.&lt;br&gt;
Windows: Manages users through Computer Management, Control Panel or PowerShell.&lt;br&gt;
Secure environments by limiting user access and enforcing best practices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Package Management&lt;br&gt;
Linux: Tools like apt (Ubuntu/Debian), yum (CentOS), handle software installation and updates.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Windows: Use the Windows Package Manager (winget) or Chocolatey.&lt;/p&gt;

&lt;p&gt;Practical Applications of OS Knowledge in DevOps&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Setting Up a Server&lt;br&gt;
Example: Deploying a web application on Linux.&lt;br&gt;
Install necessary packages (e.g., nginx, python3)&lt;br&gt;
Configure the web server to serve the application.&lt;br&gt;
Secure the server using firewalls and SSH keys.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Containerizing Applications&lt;br&gt;
Example: Using Docker.&lt;br&gt;
Understand base images (e.g., ubuntu:24.04 or alpine:latest).&lt;br&gt;
Write Dockerfiles that leverage OS commands for setup.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automating Tasks&lt;br&gt;
Example: Scheduling backups with Cron (Linux) or Task Scheduler (Windows).&lt;br&gt;
Write scripts to automate repetitive tasks.&lt;br&gt;
Schedule them to run at specific intervals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitoring and Logging&lt;br&gt;
Example: Using system logs for troubleshooting.&lt;br&gt;
Access logs in /var/log (Linux) or Event Viewer (Windows).&lt;br&gt;
Use monitoring tools like Prometheus and Grafana for system metrics.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  How to Start Learning Operating Systems for DevOps
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Choose a specific OS (Linux Distribution is preferred)&lt;br&gt;
Start with beginner-friendly distros like Ubuntu or CentOS.&lt;br&gt;
Practice basic commands and explore the directory structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set Up a Virtual Lab&lt;br&gt;
Use VirtualBox or VMware to create virtual machines.&lt;br&gt;
Experiment with Linux and Windows Server environments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learn Command-Line Basics&lt;br&gt;
Master essential commands for file management, process monitoring, and networking.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write Simple Scripts&lt;br&gt;
Automate tasks using Bash (Linux) or PowerShell (Windows).&lt;br&gt;
Gradually incorporate tools like Git, Ansible or Terraform.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Experiment with Containers&lt;br&gt;
Install Docker and create basic containers.&lt;br&gt;
Understand the relationship between the host OS and containerized applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;OS knowledge empowers DevOps practitioners to work more effectively. By mastering basic OS concepts and gradually exploring advanced topics, you can build a solid foundation for your DevOps journey.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Docker vs Virtual Machines: What’s the Difference?</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Mon, 30 Dec 2024 19:39:40 +0000</pubDate>
      <link>https://dev.to/toluwanee/docker-vs-virtual-machines-whats-the-difference-4o5o</link>
      <guid>https://dev.to/toluwanee/docker-vs-virtual-machines-whats-the-difference-4o5o</guid>
      <description>&lt;p&gt;In the world of modern IT infrastructure, Docker and Virtual Machines (VMs) are popular technologies for application deployment and resource management. While they may seem similar at first glance, they differ significantly in architecture, use cases, and resource efficiency. This article explores the key differences between Docker and Virtual Machines, their advantages, and when to use each.&lt;/p&gt;

&lt;p&gt;Let's begin from the components of an operating system, An operating system (OS) is the core software that manages a computer's hardware and software resources. There are two main components,  the user space and the kernel. &lt;/p&gt;

&lt;p&gt;User Space: &lt;br&gt;
The user space is where user applications and utilities run, interacting with the kernel via system calls. It could be via a GUI or a command line interface.&lt;/p&gt;

&lt;p&gt;Kernel: The kernel is core of the OS. It manages system resources like CPU scheduling, memory, file system, input output devices&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Virtual Machine?&lt;/strong&gt;&lt;br&gt;
A Virtual Machine (VM) is a virtualized instance of a complete operating system (OS) that runs on top of a hypervisor. VMs simulate the functionality of physical hardware, allowing multiple OS instances to run on a single physical machine. These OSes have their own User Space and Kernel, and that makes them function like a full OS.&lt;/p&gt;

&lt;p&gt;A hypervisor allows multiple operating systems to run simultaneously on a single physical server.   &lt;br&gt;
It is like a layer of software that sits between the physical hardware (CPU, RAM, storage) and the guest operating systems. It manages and allocates resources to each guest OS, making it appear to each guest as if it has exclusive access to the hardware.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features of Virtual Machines:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Full OS Virtualization: Each VM includes a full OS, its own kernel, and necessary libraries and binaries.&lt;/p&gt;

&lt;p&gt;Resource Isolation: VMs provide strong isolation, as each runs in its own environment with dedicated virtual resources.&lt;/p&gt;

&lt;p&gt;Hardware Independence: VMs abstract the underlying hardware, making them highly versatile for running different OS types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Docker?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker is an example of container technology. It is a platform for developing, shipping, and running applications in lightweight, portable containers. Containers package an application and its dependencies into a single unit that can run reliably across different computing environments. In the case of Docker, Docker only has its own user space where applications run, but it shares the kernel with the underlying OS&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features of Docker:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lightweight: Docker containers share the host operating system’s kernel, which makes them smaller and faster to start compared to VMs.&lt;/p&gt;

&lt;p&gt;Portability: A Docker container can run on any system with Docker installed, regardless of the underlying hardware or OS.&lt;/p&gt;

&lt;p&gt;Isolation: Containers operate in isolated environments, ensuring that applications do not interfere with each other.&lt;/p&gt;

&lt;p&gt;Efficiency: By sharing the host OS kernel, Docker containers use fewer resources compared to VMs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Architectural Differences&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Docker Architecture:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Docker containers share the host OS kernel.&lt;/p&gt;

&lt;p&gt;They include only the application and its dependencies.&lt;/p&gt;

&lt;p&gt;Containers run as isolated processes on the host system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Architectural flow&lt;/strong&gt;&lt;br&gt;
| Host OS |&lt;br&gt;
| Docker Daemon |&lt;br&gt;
| Container 1 | Container 2 | Container 3 |&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;VM Architecture:
Each VM includes its own OS, kernel, and application stack.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;VMs are managed by a hypervisor that abstracts the hardware.&lt;/p&gt;

&lt;p&gt;Diagram:&lt;/p&gt;

&lt;p&gt;| Host OS |&lt;br&gt;
| Hypervisor |&lt;br&gt;
| VM 1 | VM 2 | VM 3 |&lt;br&gt;
| Guest OS | Guest OS | Guest OS |&lt;/p&gt;

&lt;p&gt;Performance Comparison&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Resource Utilization&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Docker: Containers share the host OS kernel, resulting in lower overhead and better resource utilization.&lt;br&gt;
VMs: Each VM requires its own OS, which increases memory and storage usage.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Startup Time&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Docker: Containers start in seconds since they don’t require booting a full OS.&lt;br&gt;
VMs: VMs can take minutes to boot because a complete OS startup is required.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Portability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Docker: Containers are highly portable across environments as long as Docker is installed.&lt;br&gt;
VMs: Portability is limited due to dependencies on hypervisors and VM-specific formats.&lt;/p&gt;

&lt;p&gt;Security&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Docker:&lt;br&gt;
Containers share the host OS kernel, which can pose security risks if the host is compromised.&lt;br&gt;
Security relies on namespaces, control groups (cgroups), and additional tools like SELinux or AppArmor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;VMs:&lt;br&gt;
VMs provide strong isolation as each has its own kernel.&lt;br&gt;
Even if a VM is compromised, it is unlikely to affect others or the host system.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Use Case Scenarios&lt;/strong&gt;&lt;br&gt;
When to Use Docker:&lt;br&gt;
Microservices Architecture: Ideal for deploying microservices as containers are lightweight and scalable.&lt;br&gt;
CI/CD Pipelines: Frequently used in DevOps workflows for rapid testing and deployment.&lt;br&gt;
Application Portability: Ensures consistency across development, testing, and production environments.&lt;/p&gt;

&lt;p&gt;When to Use Virtual Machines:&lt;br&gt;
Running Multiple OS Types: Useful for running applications that require different OS environments.&lt;br&gt;
Legacy Application Support: Suitable for applications that require complete OS environments.&lt;br&gt;
Strong Isolation: Best for scenarios that require enhanced security and resource isolation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros and Cons&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker:&lt;/strong&gt;&lt;br&gt;
Pros&lt;br&gt;
Lightweight and fast&lt;br&gt;
Limited security isolation&lt;br&gt;
High portability&lt;br&gt;
Easy to deploy and manage&lt;/p&gt;

&lt;p&gt;Cons&lt;br&gt;
Requires container orchestration tools for scaling&lt;br&gt;
Kernel dependency on the host&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual Machines:&lt;/strong&gt;&lt;br&gt;
Pros&lt;br&gt;
Strong isolation&lt;br&gt;
High resource consumption&lt;br&gt;
Supports multiple OS types&lt;/p&gt;

&lt;p&gt;Cons&lt;br&gt;
Slower startup times&lt;br&gt;
Mature technology&lt;br&gt;
Less portable than containers&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Docker and Virtual Machines are powerful technologies, but they serve different purposes. Docker excels in scenarios where speed, portability, and resource efficiency are critical. In contrast, Virtual Machines are better suited for use cases requiring robust isolation, multiple OS environments, or support for legacy applications.&lt;/p&gt;

&lt;p&gt;Knowing what the differences and strengths of each of them aids in choosing the best tools for our application needs. Often, a combination of both technologies can be used to build flexible and scalable infrastructures.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>virtualmachine</category>
    </item>
    <item>
      <title>Learning DevOps: Setting Up a Local Workflow System Without the Cloud</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Mon, 30 Dec 2024 19:33:54 +0000</pubDate>
      <link>https://dev.to/toluwanee/learning-devops-setting-up-a-local-workflow-system-without-the-cloud-46oo</link>
      <guid>https://dev.to/toluwanee/learning-devops-setting-up-a-local-workflow-system-without-the-cloud-46oo</guid>
      <description>&lt;p&gt;DevOps has become an essential practice in modern software development and IT operations, with the cloud playing a significant role in enabling automation, scalability, and collaboration. However, cloud platforms often come with recurring costs and require an internet connection, which may not always be ideal for beginners or enthusiasts. Building your own personal setup provides an excellent alternative for learning DevOps concepts in a hands-on, cost-effective manner.&lt;/p&gt;

&lt;p&gt;In this article, we’ll explore why a personal setup is valuable, what you need to set one up, and how to create your own DevOps practice setup without relying on the cloud. In the basic form of cloud computing, the main thing that makes the cloud different is accessing computing resources over the internet, so what if you could do the same on your PC without subscribing to a cloud provider.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Consider a Personal Setup Instead of the Cloud?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;br&gt;
Cost Savings: No monthly subscription fees for cloud services. You can repurpose old hardware.&lt;br&gt;
Offline Access: Learn and experiment even without an internet connection.&lt;br&gt;
Privacy and Control: Complete ownership of your data and setup.&lt;br&gt;
Hands-On Learning: Gain deeper insights into infrastructure, networking, and system administration by managing everything locally.&lt;/p&gt;
&lt;h3&gt;
  
  
  What you need to setup one
&lt;/h3&gt;

&lt;p&gt;Essential Components of a Personal Setup&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hardware Requirements&lt;/strong&gt;&lt;br&gt;
PCs or Laptops: Ensure adequate RAM (8GB minimum), CPU (4 cores or more), and storage (SSD recommended).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Software and Tools&lt;/strong&gt;&lt;br&gt;
Virtualization Tools:&lt;br&gt;
VirtualBox for lightweight virtualization needs.&lt;br&gt;
VMware Workstation is another software for managing virtual machines.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Operating Systems&lt;/strong&gt;&lt;br&gt;
Linux distributions such as Ubuntu Server, CentOS, or Debian for hosting services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Networking Tools and remote connection tools&lt;/strong&gt;&lt;br&gt;
OpenVPN or OpenSSH for remote access on your personal setup&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Tools for DevOps Practice&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Version Control: Git for managing code.&lt;br&gt;
CI/CD Pipelines: Jenkins, GitLab CI, or GitHub Actions.&lt;br&gt;
Configuration Management: Ansible, Chef, or Puppet.&lt;br&gt;
Infrastructure as Code (IaC): Terraform for provisioning infrastructure.&lt;br&gt;
Monitoring and Logging: Prometheus, Grafana, and ELK stack.&lt;br&gt;
Containerization Platforms:&lt;br&gt;
Docker for running and managing containers.&lt;br&gt;
Kubernetes (K3s or MicroK8s) for orchestrating containerized applications.&lt;/p&gt;
&lt;h1&gt;
  
  
  Setting Up Your Personal Setup (the real deal)
&lt;/h1&gt;
&lt;h3&gt;
  
  
  Step 1: Define Your Goals
&lt;/h3&gt;

&lt;p&gt;First things first, determine what you want to achieve with your personal setup. Common goals include:&lt;br&gt;
Learning Linux system administration.&lt;br&gt;
Hosting a website or web software locally.&lt;br&gt;
Practicing containerization and orchestration with Docker and Kubernetes.&lt;br&gt;
Building and deploying CI/CD pipelines.&lt;br&gt;
Exploring networking concepts.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Set Up the Setup
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;The setup here will be for a web software&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Prepare the Hardware&lt;/strong&gt;:&lt;br&gt;
Choose a machine&lt;br&gt;
Ensure adequate RAM (8GB minimum), CPU (4 cores or more), and storage&lt;br&gt;
If you are on a windows enable virtualization from your BIOS&lt;br&gt;
Install a hypervisor like VirtualBox.&lt;br&gt;
Install any of the linux distros as base operating system on the hypervisor, there are 2 ways you can go about this.&lt;br&gt;
a. Install from scratch &lt;br&gt;
Use a stable Linux distribution from scratch such as Ubuntu Server or Debian.&lt;br&gt;
Configure SSH for remote access.&lt;/p&gt;

&lt;p&gt;b. Install via osboxes.org, which is what we will be doing. Preconfigured images are found here( I advise you go for this, since it is faster and you will be using it for practice)&lt;/p&gt;

&lt;p&gt;Select the VM images dropdown&lt;br&gt;
Click on virtual box images at the top, it will take you to page with a list of operating systems.&lt;br&gt;
Go to &lt;a href="https://www.osboxes.org/" rel="noopener noreferrer"&gt;https://www.osboxes.org/&lt;/a&gt; and download your preferred linux distro.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi1ohpkyhhmu5srvxgype.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi1ohpkyhhmu5srvxgype.png" alt="Image description" width="800" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select ubuntu on the new page (choose the distro of your choice).&lt;br&gt;
Download VirtualBox (VDI) image &lt;br&gt;
I am downloading Ubuntu in this case.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrx8k3orx2gzc8t4j962.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrx8k3orx2gzc8t4j962.png" alt="Image description" width="800" height="328"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The good thing about osboxes is that it is very fast to install&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Download the your preferred version. I am downloading the 24.10 Oracular Oriole, and my hardware is a 64bit version (choose what matches your hardware)&lt;br&gt;
&lt;em&gt;Take note of the username and password in the info section&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yz7pn0t16hls4gq8kgc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yz7pn0t16hls4gq8kgc.png" alt="Image description" width="800" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Save and extract the OS image to a folder.&lt;/p&gt;

&lt;p&gt;On the virtual box interface, click on new, name your OS and select its type and version.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2jrjwo4x7wyovzdyxx0j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2jrjwo4x7wyovzdyxx0j.png" alt="Image description" width="800" height="342"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The folder is where my VMs are stored, you can use any foler of your choice. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2cfw7xntxlak5x8mp53x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2cfw7xntxlak5x8mp53x.png" alt="Image description" width="723" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next allocate memory (RAM- 2 or 4GB) and processors(you can use 2),  that will be available for the new virtual machine, then click next&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fohm7n6symtcrfnf8we8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fohm7n6symtcrfnf8we8l.png" alt="Image description" width="725" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select "Use an existing virtual hard disk file" and browse to the folder that contains the extracted disk image. The disk must be present in this path must be present for the machine to work.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frs7f5y7meonvk0dtfebc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frs7f5y7meonvk0dtfebc.png" alt="Image description" width="725" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click Finish&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1pgrm436an9ia1lfl3g3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1pgrm436an9ia1lfl3g3.png" alt="Image description" width="722" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your new virtual machine has been created.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F954n7fvv3ab25oewpqug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F954n7fvv3ab25oewpqug.png" alt="Image description" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right click on the new OS and click on settings&lt;br&gt;
You can reset the processor, storage you want to allocate to the virtual machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NETWORK&lt;/strong&gt;&lt;br&gt;
Go to network &lt;br&gt;
Set the network to bridged adapter, this helps the virtual machine to get its own IP address as well as connect to the internet.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frhvic6lgjze6zikdj2wo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frhvic6lgjze6zikdj2wo.png" alt="Image description" width="631" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Start the VM to test, configure the settings as desired, and install anything you will need for the other machines as this will serve as the base for other machines, then shut it down after testing, to create clones.&lt;br&gt;
&lt;em&gt;the password is at info section of the osboxes website&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Example tools you might need to install:&lt;br&gt;
Docker and Kubernetes:&lt;br&gt;
check if openssh is present&lt;br&gt;
Install Docker for containerization.&lt;br&gt;
Set up Kubernetes (K3s for lightweight clusters).&lt;br&gt;
Ansible, Jenkins or GitLab CI for building and applications.&lt;br&gt;
And many more softwares required&lt;/p&gt;

&lt;p&gt;type ifconfig to check for the ip address&lt;br&gt;
if 'ifconfig' is not installed, follow the installation process. use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; sudo apt install net-tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97ompvxlacu5xwwxj61z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97ompvxlacu5xwwxj61z.png" alt="Image description" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;run ifconfig again&lt;br&gt;
&lt;em&gt;I blocked you from seeing my ip address&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpl2loolpvzkipu5jbho2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpl2loolpvzkipu5jbho2.png" alt="Image description" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;check if openssh is present&lt;/strong&gt;
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status ssh 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If not, follow the following commands to install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install the OpenSSH server package with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install openssh-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the status of the SSH service to ensure it's installed and running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the SSH service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable the SSH service to start on boot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the status of the SSH service again to ensure it's installed and running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6wtoqudaiga38dug0gnd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6wtoqudaiga38dug0gnd.png" alt="Image description" width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;if it does not work as shown, follow the steps from the ssh section again.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;shutdown the machine.&lt;/p&gt;

&lt;p&gt;If you are on a windows machine, you can use mobaxterm to test and connect your VM via ssh.&lt;/p&gt;

&lt;h3&gt;
  
  
  CLONE THE VIRTUAL MACHINES
&lt;/h3&gt;

&lt;p&gt;Right click on the newly created virtual machine and click clone.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmuksgjbhy5i90wng89hg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmuksgjbhy5i90wng89hg.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;name the first clone, I am naming mine "client machine" because that is what I intend to use as my local PC.&lt;br&gt;
&lt;strong&gt;Ensure Generate new MAC addresses for all network adapters is selected&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2eh74f0oidfa7qojeint.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2eh74f0oidfa7qojeint.png" alt="Image description" width="582" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on linked clone(it saves space), then select finish&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvjp09j10uwmiuf8vtb73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvjp09j10uwmiuf8vtb73.png" alt="Image description" width="582" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Repeat the cloning process for &lt;strong&gt;main-server, target-server1, target-server2&lt;/strong&gt;. You will have something like at the end.&lt;br&gt;
&lt;strong&gt;Remember: Generate new MAC addresses for all network adapters is selected&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgavf85v8yr40lnbvpxel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgavf85v8yr40lnbvpxel.png" alt="Image description" width="532" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sample setup&lt;br&gt;
Start the client-machine and the target-server1.&lt;/p&gt;

&lt;p&gt;let's change the name of the virtual machines from 'osboxes' to a preferred name. I am using 'clientmachine and targetserver1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/hostname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx420jrw1j28jf44wbenk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx420jrw1j28jf44wbenk.png" alt="Image description" width="520" height="140"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtsytsagcinrmd6ot0wg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtsytsagcinrmd6ot0wg.png" alt="Image description" width="800" height="521"&gt;&lt;/a&gt;&lt;br&gt;
restart the machine and see the hostname change&lt;/p&gt;

&lt;p&gt;open target-server1 machine and repeat the same steps, if you are familiar with ssh, login with ssh.&lt;/p&gt;

&lt;p&gt;your output should look like this&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fitfiak02mabypnntuogq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fitfiak02mabypnntuogq.png" alt="Image description" width="800" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Restart the machine and see the hostname change.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkstimcj9kskzgr7s52wi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkstimcj9kskzgr7s52wi.png" alt="Image description" width="800" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, follow this step-by-step guide to create a basic HTML website, test it locally, and then host it on your server with Nginx:&lt;br&gt;
If you are familiar with creating basic HTML site and setting up nginx server, you can skip this part&lt;/p&gt;

&lt;p&gt;create a basic html page on your client and test it.&lt;br&gt;
Create the project folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir my-website
cd my-website
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the HTML file: Create an index.html file in the my-website folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Page Title&amp;lt;/title&amp;gt;
&amp;lt;meta charset="UTF-8"&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;
&amp;lt;style&amp;gt;
body {
  font-family: Arial, Helvetica, sans-serif;
}
&amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;h1&amp;gt;My Website&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;A website created by me.&amp;lt;/p&amp;gt;

&amp;lt;/body
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.w3schools.com/howto/howto_make_a_website.asp" rel="noopener noreferrer"&gt;example from w3schools&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;firefox index.html&lt;/code&gt;  in the cli to view the website&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;setup your server with this guide&lt;/li&gt;
&lt;li&gt;Access the server:
Use SSH to access your server:
you can access it directly since it is on your computer, but I advise you use ssh, so you learn how to get into a real cloud environment
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh user@your-server-ip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Update and install necessary packages:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Update the system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Nginx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install nginx -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Verify Nginx installation:
Start Nginx:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Upload Your Website to the Server&lt;br&gt;
Copy files to the server:&lt;br&gt;
Use scp to upload your website files:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ensure you run this command from the client machine when&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scp -r my-website/* user@your-server-ip:/home/user/my-website/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Move files to the Nginx directory:&lt;br&gt;
SSH into the server and move the website files to the default Nginx web directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mv /home/user/my-website/* /var/www/html/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4: Configure Nginx for Your Website&lt;br&gt;
Edit the Nginx configuration:&lt;/p&gt;

&lt;p&gt;Open the Nginx configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/nginx/sites-available/default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update the server block to look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
    listen 80;
    server_name your-domain.com;

    root /var/www/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the Nginx configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nginx -t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload Nginx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl reload nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 5: Verify the Website on the Server&lt;br&gt;
Open your server’s IP address (e.g., &lt;a href="http://your-server-ip" rel="noopener noreferrer"&gt;http://your-server-ip&lt;/a&gt;) in a browser. You should see your website. Your server ip is the one that is shown when you use the &lt;code&gt;ifconfig&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;If you have a domain, point it to your server’s IP address by updating the domain’s DNS settings. After DNS propagation, you can access the site using your domain.&lt;/p&gt;

&lt;p&gt;Take note that the IP that is being mapped to this domain must be consistent with the ip of your server at any point in time, so be sure to update the ip accordingly whenever there is a restart, shutdown of server or any event that can trigger a change in the ip of your server machine.&lt;/p&gt;

&lt;p&gt;If you do not want to go through the stress of constantly updating the DNS on a global accessibility scale, you can simply limit the availability and change to your local client machine by updating its hosts files in the &lt;code&gt;/etc/hosts&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your output will be something like this&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ptjkgnbcbp96lpgkg39.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ptjkgnbcbp96lpgkg39.png" alt="Image description" width="800" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run this system for other tools like ansible and kubernetes like you would have done on a cloud sever, using the main server and the target servers on local like you would on the cloud.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>linux</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Linux User Creation Bash Script</title>
      <dc:creator>Oni Toluwalope</dc:creator>
      <pubDate>Wed, 03 Jul 2024 17:26:19 +0000</pubDate>
      <link>https://dev.to/toluwanee/linux-user-creation-bash-script-5d3b</link>
      <guid>https://dev.to/toluwanee/linux-user-creation-bash-script-5d3b</guid>
      <description>&lt;p&gt;This Bash script automates the creation of user accounts and group memberships in Ubuntu. It takes a text file as input, where each line specifies a username and the groups they should belong to (comma-separated). The script performs the following actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reads the user and group information from the text file.&lt;/li&gt;
&lt;li&gt;Creates user accounts if they don't already exist.&lt;/li&gt;
&lt;li&gt;Creates groups if they don't already exist.&lt;/li&gt;
&lt;li&gt;Adds users to the specified groups.&lt;/li&gt;
&lt;li&gt;Generates random passwords for each user.&lt;/li&gt;
&lt;li&gt;Sets permissions and ownership for user home directories.&lt;/li&gt;
&lt;li&gt;Logs its actions in a file for reference.&lt;/li&gt;
&lt;li&gt;This script simplifies user and group management, saving time and reducing the risk of errors compared to manual configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each User must have a personal group with the same group name as the username, this group name will not be written in the text file.&lt;br&gt;
 A user can have multiple groups, each group delimited by comma ","&lt;br&gt;
 Usernames and user groups are separated by semicolon ";"- Ignore whitespace&lt;br&gt;
e.g.&lt;br&gt;
 Tolu;developer,tester,security&lt;/p&gt;

&lt;p&gt;Code Breakdown.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#!/bin/bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Helps the script to run in a bash shell once called.&lt;br&gt;
This shebang! establishes a well-defined environment for the script&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defining Variables:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;logfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/var/log/user_management.log"&lt;/span&gt;

&lt;span class="nv"&gt;password_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/var/secure/user_passwords.csv"&lt;/span&gt;

&lt;span class="nv"&gt;text_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script utilizes variables to store crucial paths and user input. This enhances readability and maintainability. Here's a breakdown of the defined variables:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;logfile&lt;/code&gt;: This variable holds the path for the log file where the script's actions are recorded. By default, it points to &lt;code&gt;/var/log/user_management.log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;       &lt;code&gt;password_file&lt;/code&gt;: This variable stores the path to the password file. This file securely stores usernames and their corresponding randomly generated passwords. The default location is &lt;code&gt;/var/secure/user_passwords.csv&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;       &lt;code&gt;text_file&lt;/code&gt;: This variable captures the filename provided by the user as the first argument (&lt;code&gt;$1&lt;/code&gt;). This file is expected to contain a list of usernames and their associated groups, separated by semicolons.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Input Validation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The script ensures proper user input by performing validation. It checks if the user has provided the essential text file containing user and group information. Here's the code snippet for this validation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$text_file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
       &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: Usage: &lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt; &amp;lt;name of text file&amp;gt;"&lt;/span&gt;
       &lt;span class="nb"&gt;exit &lt;/span&gt;1
   &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This block of code checks if the &lt;code&gt;text_file&lt;/code&gt; variable is empty.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the file is missing, an error message is displayed, informing the user of the correct usage (&lt;code&gt;echo&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;The script exits with an error code (&lt;code&gt;exit 1&lt;/code&gt;) to indicate an issue with the input.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  File Management: Creating Essential Files
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Creating Directories:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The script employs the &lt;code&gt;mkdir -p&lt;/code&gt; command to create the directory structure for the password file if it doesn't already exist. This ensures the script doesn't encounter errors due to missing directories. The &lt;code&gt;-p&lt;/code&gt; flag in &lt;code&gt;mkdir&lt;/code&gt; instructs it to create parent directories if necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Creating Log and Password Files:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;touch&lt;/code&gt; command is used to create the log file (&lt;code&gt;$logfile&lt;/code&gt;) and password file (&lt;code&gt;$password_file&lt;/code&gt;). This establishes empty files for the script to record its actions and store passwords.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Setting Permissions:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The script prioritizes security by setting strict permissions (600) for the password file using &lt;code&gt;chmod 600 "$password_file"&lt;/code&gt;. This restricts access to the file, allowing only the owner to read and write to it. This prevents unauthorized access to sensitive password information.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Building Users and Groups: The actual automation section
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;generate_random_password&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;This function generates a secure and random password for each user.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="k"&gt;function &lt;/span&gt;generate_random_password&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="nv"&gt;10&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;  &lt;span class="c"&gt;# Default length of 10 characters&lt;/span&gt;
      &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="nt"&gt;-dc&lt;/span&gt; &lt;span class="s1"&gt;'A-Za-z0-9!?%+='&lt;/span&gt; &amp;lt; /dev/urandom | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$length&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;The function leverages &lt;code&gt;/dev/urandom&lt;/code&gt; to access a cryptographically secure random number generator.&lt;/li&gt;
&lt;li&gt;It utilizes the &lt;code&gt;tr&lt;/code&gt; command for character filtering. This ensures the password includes alphanumeric characters, special symbols (&lt;code&gt;!?%+=&lt;/code&gt;), and avoids potential issues with spaces in passwords.&lt;/li&gt;
&lt;li&gt;Finally, &lt;code&gt;head -c "$length"&lt;/code&gt; extracts the desired number of characters to form the random password.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;log_message&lt;/code&gt; Function&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;This function simplifies logging by appending a timestamp and the script filename (&lt;code&gt;$text_file&lt;/code&gt;) to the log file (&lt;code&gt;$logfile&lt;/code&gt;). Here's the code:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="k"&gt;function &lt;/span&gt;log_message&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="s1"&gt;'+%Y-%m-%d %H:%M:%S'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; - &lt;/span&gt;&lt;span class="nv"&gt;$text_file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$logfile&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;date&lt;/code&gt; command with the &lt;code&gt;'+%Y-%m-%d %H:%M:%S'&lt;/code&gt; format generates a timestamp for each log message.&lt;/li&gt;
&lt;li&gt;The entire message is then appended to the log file using &lt;code&gt;echo &amp;gt;&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;&lt;code&gt;create_user&lt;/code&gt; Function and User Creation *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;This function handles user creation based on the user information in the text file. Here's a breakdown:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="k"&gt;function &lt;/span&gt;create_user&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;username&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
      &lt;span class="nb"&gt;local groups&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

      &lt;span class="k"&gt;if &lt;/span&gt;getent passwd &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null&lt;span class="p"&gt;;&lt;/span&gt; 
  &lt;span class="k"&gt;then
          &lt;/span&gt;log_message &lt;span class="s2"&gt;"User &lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt; already exists"&lt;/span&gt;
      &lt;span class="k"&gt;else
          &lt;/span&gt;useradd &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
          log_message &lt;span class="s2"&gt;"Created user &lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
      &lt;span class="k"&gt;fi&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;It takes two arguments: &lt;code&gt;username&lt;/code&gt; and &lt;code&gt;groups&lt;/code&gt; (comma-separated list).&lt;/li&gt;
&lt;li&gt;The function first checks if the user already exists using &lt;code&gt;getent passwd "$username" &amp;gt; /dev/null&lt;/code&gt;. If the command exits successfully, it means the user exists.&lt;/li&gt;
&lt;li&gt;If the user doesn't exist:

&lt;ul&gt;
&lt;li&gt;The script creates the user's home directory with &lt;code&gt;useradd -m "$username"&lt;/code&gt;. The &lt;code&gt;-m&lt;/code&gt; flag instructs &lt;code&gt;useradd&lt;/code&gt; to create a home directory for the user.&lt;/li&gt;
&lt;li&gt;A success message regarding user creation is logged using &lt;code&gt;log_message&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Otherwise, a message indicating the user already exists is logged.&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Group Management and User-Group Associations&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The script iterates through each line in the text file, processing users and their assigned groups. Here's the process:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      while IFS=';' read -r username groups; do
          create_user "$username" "$groups"

          groups_array=($(echo $groups | tr "," "\n"))

          for group in "${groups_array[@]}";

         do

          if ! getent group "$group" &amp;gt; /dev/null; 

   then

  groupadd "$group"

  log_message "Group created $group"

  else

  log_message "Group $group already exists"

  fi

  usermod -aG "$group" "$username"

  log_message "Added user $username to group $group"

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

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  - A `while` loop iterates through each line in the `text_file` 
      - Inside the loop:
          - The `create_user` function is called to create the user (already described earlier).
          - The comma-separated groups are split into an array (`groups_array`) using `tr` for easier processing.
          - Another loop iterates through each group in the `groups_array`.
              - It checks if the group exists using `getent group "$group" &amp;gt; /dev/null`.
`getend` is a command used to request file from database in the CLI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Security Home and Password Assignment:
&lt;/h2&gt;

&lt;p&gt;security and finalizing the user setup:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Home Directory Permissions&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The script prioritizes security by setting appropriate permissions for each user's home directory. Here's the code:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;chmod &lt;/span&gt;700 &lt;span class="s2"&gt;"/home/&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="nb"&gt;chown&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"/home/&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  log_message &lt;span class="s2"&gt;"Set up home directory for user &lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;The script restricts access to the user's home directory by setting permissions to 700 with &lt;code&gt;chmod 700 "/home/$username"&lt;/code&gt;. This grants read, write, and execute permissions only to the owner (the user).&lt;/li&gt;
&lt;li&gt;Ownership of the home directory is then transferred to the user with &lt;code&gt;chown "$username:$username" "/home/$username"&lt;/code&gt;. This ensures the user has full control over their home directory and its contents.&lt;/li&gt;
&lt;li&gt;A success message regarding home directory setup is logged.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Password Assignment&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The script assigns a unique and secure password to each user. Here's the process:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nv"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;generate_random_password   &lt;span class="c"&gt;# Generate 10-character password&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;$password&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | chpasswd
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;$password&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$password_file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  log_message &lt;span class="s2"&gt;"Set password for &lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;ul&gt;
&lt;li&gt;It utilizes the &lt;code&gt;generate_random_password&lt;/code&gt; function (described earlier) to create a 10-character random password for each user.&lt;/li&gt;
&lt;li&gt;The username and password are combined (&lt;code&gt;"$username:$password"&lt;/code&gt;) and used with &lt;code&gt;chpasswd&lt;/code&gt; to set the password for the user.&lt;/li&gt;
&lt;li&gt;The script then stores both the username and the randomly generated password in the secure password file (&lt;code&gt;"$password_file"&lt;/code&gt;) for reference.&lt;/li&gt;
&lt;li&gt;Finally, a success message regarding password assignment is logged.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Bringing it All Together:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

#Log file and password location
logfile="/var/log/user_management.log"
password_file="/var/secure/user_passwords.csv"
text_file=$1

#check for file input
if [ -z "$text_file" ]
then
echo "Usage is: $0 &amp;lt;name of text file&amp;gt;"
exit 1
fi

#Create Log file and password files
mkdir -p /var/secure
touch $logfile $password_file
chmod 600 $password_file

#function to generate randompasswords
generate_random_password() {
  local length=${1:-10}
  tr -dc 'A-Za-z0-9!?%+=' &amp;lt; /dev/urandom | head -c $length
}

log_message() {
  echo "$(date '+%Y-%m-%d %H:%M:%S') - $text_file" &amp;gt;&amp;gt; $logfile
}

#FUNCTION TO CREATE USER
create_user() {
local username=$1
local groups=$2

if getent passwd "$username" &amp;gt; /dev/null;
then
 log_message "User $username already exists"
else
  useradd -m $username
  log_message "Created  user $username"
fi

#Adding user to groups
groups_array=($(echo $groups | tr "," "\n"))
for group in "${groups_array[@]}";
do
  if ! getent group "$group" &amp;gt; /dev/null; 
then
  groupadd "$group"
  log_message "Group created $group"
  else
  log_message "Group $group already exists"
  fi
  usermod -aG "$group" "$username"
  log_message "Added user $username to group $group"
done

chmod 700 /home/$username
chown $username:$username /home/$username
log_message "Set up home directory for user $username"

#Assigning Random password to users
password=$(generate_random_password 12)
echo "$username:$password" | chpasswd
echo "$username,$password" &amp;gt;&amp;gt; $password_file
log_message "Set password for $username"
}

while IFS=';' read -r username groups;
do
  create_user "$username" "$groups"
  done &amp;lt; "$text_file"

echo "User creation done." | tee -a $logfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By combining these steps, the script automates the creation of user accounts, assigns them to designated groups, ensures secure home directory permissions, and provides a record of usernames and randomly generated passwords. This script streamlines user and group management, saving time and effort while promoting security best practices.&lt;/p&gt;

&lt;p&gt;I am open to receiving comments with questions or suggestions that improves the script. Cheers!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Toluwanee/linux-user-creation-bash-script.git" rel="noopener noreferrer"&gt;Link to github repo&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
