<?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 Galvez Josue on Medium]]></title>
        <description><![CDATA[Stories by Galvez Josue on Medium]]></description>
        <link>https://medium.com/@josue.galvez?source=rss-98f4576424c4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Galvez Josue on Medium</title>
            <link>https://medium.com/@josue.galvez?source=rss-98f4576424c4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 22:02:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@josue.galvez/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[Linux Data Manipulation, Archiving, and Automation]]></title>
            <link>https://medium.com/@josue.galvez/linux-data-manipulation-archiving-and-automation-a431676dc7b7?source=rss-98f4576424c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a431676dc7b7</guid>
            <dc:creator><![CDATA[Galvez Josue]]></dc:creator>
            <pubDate>Thu, 19 Jun 2025 14:06:49 GMT</pubDate>
            <atom:updated>2025-06-19T18:20:50.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*MAdWb4KDW48vycokEzEdYg.png" /></figure><h3>Introduction</h3><p>As part of a recent Linux project, I needed to clean up and organize some raw data. Instead of handling everything manually I decided to automate the entire process from separating files and replacing specific words to deleting unwanted content and archiving the final result. This blog walks through the exact steps I took, including the script I wrote to filter the final output. It was a great exercise in using basic Linux tools to solve a real-world problem.</p><h3>Key Steps:</h3><p>1. Create /opt/appdata directory.</p><p>2. Copy hidden and non-hidden files into separate subfolders.</p><p>3. Perform some data manipulation.</p><p>4. Archive the data as /opt/appdata.tar.gz.</p><p>5. Create a soft link at /home/jgalvez/appdata.tar.gz.</p><p>6. Set sticky bit and change archive ownership to jgalvez.</p><p>7. Create a script to extract “processed” lines into a file.</p><h3>Step 1: Create the Working Directory</h3><p>First, create the main directory where all processing will occur.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*TQkygBdOlIwp1uzNXFaIGg.png" /></figure><h3>Step 2: Separate Hidden and Non-Hidden Files</h3><p>I separated hidden files (those starting with a dot) and non-hidden files into their own folders within /opt/appdata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*nlartfwx8lkTPidbKTZvLA.png" /></figure><ul><li>Copy hidden and regular files</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*q8F1HqvhXM8Ep89C8OS0Tg.png" /></figure><h3>Step 3: Data Manipulation</h3><p>Replace “yes” with “no” in all files within /opt/appdata directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*7Wg3XlhwBBnfu_0xSRAaBA.png" /></figure><p>Replace all case-insensitive instances of “raw” with “processed”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*iDBa84iMxHp4j4-L3far_w.png" /></figure><p>Remove files containing Words Ending with “t” (case-sensitive)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*oipiAxYeRhmE3S16xWusGw.png" /></figure><h3>Step 4: Archive the Processed Data</h3><p>Create a tarball of /opt/appdata containing the final data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*t6pKiR3hZINN3DFTyYgMjw.png" /></figure><h3>Step 8: Create a Soft Link for Convenience</h3><p>Create a symbolic link pointing to the archive for quick access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*MDlMPG-6eH3ZilA1lk6WVg.png" /></figure><h3>Step 9: Secure Permissions</h3><p>Add a sticky bit on /opt/appdata (to restrict deletion) and change ownership of the archive to user and group <strong>jgalvez</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*Fg7uo5RI4f_0a6vySLXOpQ.png" /></figure><h3>Step 10: Automate with a Script</h3><p>This script includes commands for filtering and archiving. An important part of the script filters lines containing the word <strong>“processed”</strong> from the archive and saves them to a separate file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*saGyMJLUrRK_uF19Xf4PrQ.png" /></figure><h3>Final Thoughts</h3><p>Working through this project reminded me how powerful Linux tools can be for everyday tasks. Automating the cleanup and archiving saved me time, hassle, and made the whole process way easier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a431676dc7b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Server Automation with Podman, Scripts, and Cron Jobs]]></title>
            <link>https://medium.com/@josue.galvez/linux-server-automation-with-podman-scripts-and-cron-jobs-b9e5a978d6bc?source=rss-98f4576424c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9e5a978d6bc</guid>
            <dc:creator><![CDATA[Galvez Josue]]></dc:creator>
            <pubDate>Fri, 13 Jun 2025 21:23:21 GMT</pubDate>
            <atom:updated>2025-06-16T19:13:47.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*iX_cqwmv_BqA3BjNZsVJbQ.png" /></figure><p>Hey everyone! I recently worked on a cool Linux project involving Podman, system admin tasks, and some networking magic.</p><h3>Overview</h3><p>In this project, I will:</p><ol><li>Create a new user and add it to the Wheel group.</li><li>Restrict the “<strong>su</strong>” usage command to the wheel group.</li><li>Pull and run an <strong>NGINX</strong> container named <strong>myapp.</strong></li><li>Control the container with start/stop <strong>bash scripts</strong>.</li><li>Automate those scripts with <strong>cron</strong> jobs.</li><li>Add an extra <strong>IP</strong> to our network interface.</li><li>Install and set the <strong>MariaDB </strong>server.</li><li>Add a local <strong>DNS</strong> entry for database hostname resolution.</li></ol><h4>Step 1: Create user “josue” and add him to the Wheel group</h4><p>To ensure <strong>josue</strong> can run <strong>sudo</strong> commands, I added him to the wheel group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*N8bdKN2iAZIVpTUwxbjItQ.png" /></figure><h4>Step 2: Restrict the “<strong>switch user” command </strong>to the Wheel Group</h4><p>For better control, I modified the PAM configuration for the <strong>su</strong> command to allow ONLY users in the wheel group to use the <strong>su command.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*fy5NMCZiq3f_m0WP-dU7Ww.png" /><figcaption>Open <strong>vim /etc/pam.d/su </strong>and uncomment this line</figcaption></figure><h4>Step 3: Install Podman, Pull Image, and build “myapp” Container</h4><p><strong>dnf install -y podman</strong> # podman installation</p><p><strong>podman pull nginx</strong> # downloads the nginx image</p><p><strong>podman run -d — name myapp -p 8080:80 nginx # </strong>runs an nginx container named “myapp” in the background, mapping host port 8080 to the container’s port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NWJpBRt0luh8jGTBmXp_Hw.png" /><figcaption>nginx container running</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Py14fnBuECdTq2MfcMPROQ.png" /><figcaption>nginx web server welcome page</figcaption></figure><h4><strong>Step 4: Create Start and Stop Scripts to automate with cron</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*Ly2j8v-hge9LWA6gg3rPbA.png" /><figcaption>automation scripts</figcaption></figure><p><strong>sudo crontab -u josue -e</strong> # opens the crontab editor to edit scheduled tasks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*pgQp-RF1ub9Z3Zr7aSbGxA.png" /><figcaption>The container will start at 8 AM and stop at midnight every day.</figcaption></figure><h4>Step 5: Add an Extra IP to interface <strong>ens160</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*jFUinjggjAIP_yZ7Iphjgg.png" /></figure><h4>Step 6: Install MariaDB Server And Start Service</h4><p><strong>sudo dnf install -y mariadb-server</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X57Y8nRaGJB6GWPcDuNFng.png" /><figcaption>MariaDB service running</figcaption></figure><h4>Step 7: Add Local DNS Entry for MariaDB server</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*y1Cf4a-B8KOJtLESfzDwBw.png" /><figcaption>Edit the /etc/hosts file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*y65fz2dKdMI-2DVhC9OQlA.png" /><figcaption>Ping the database to test DNS</figcaption></figure><h3>Final Thoughts</h3><p>This project integrates containerization with Podman, Linux system administration, scripting, cron scheduling, networking, and database management, making it a great hands-on learning experience as I prepare for my RHCSA certification.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9e5a978d6bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Simple Linux High-Performance Computing Cluster]]></title>
            <link>https://medium.com/@josue.galvez/building-a-simple-linux-high-performance-computing-cluster-e5d0ce03436b?source=rss-98f4576424c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5d0ce03436b</guid>
            <dc:creator><![CDATA[Galvez Josue]]></dc:creator>
            <pubDate>Thu, 01 May 2025 00:15:27 GMT</pubDate>
            <atom:updated>2025-05-09T13:12:41.777Z</atom:updated>
            <content:encoded><![CDATA[<p>As someone who’s always been curious about how large-scale computing works, I recently decided to dive into the world of <strong>High Performance Computing (HPC)</strong>, but on a budget and at home. I used three Red Hat Linux virtual machines and an NFS server to simulate a basic HPC cluster. This project helped me understand core HPC concepts like job scheduling, node configuration, and shared storage.</p><h4>Project Goal</h4><p>Set up a simple HPC cluster using:</p><ul><li>rhel-head (scheduler, NFS Server)</li><li>rhel-node1 &amp; rhel-node2 (running compute jobs)</li><li>A shared NFS storage setup</li></ul><h4>Step 1: Configuring the Head Node (rhel-head)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AVKBa93neItF1nhz2zYzlg.png" /><figcaption>Installing required packages</figcaption></figure><p><strong><em>Package Explanation:</em></strong></p><ol><li><strong>nfs-utils:</strong> Enables NFS for sharing directories across systems.</li></ol><p>2. <strong>slurm:</strong> Installs SLURM basics for job scheduling.</p><p>3. <strong>slurm-slurmd:</strong> Runs on compute nodes; executes and manages tasks the controller sends (Head Node).</p><p>4. <strong>slurm-slurmctld:</strong> Runs on the head node, schedules jobs, and manages cluster resources.</p><p><strong><em>Create and export a shared directory</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oche6657xtjgt0e5Hk6j7g.png" /><figcaption>Enabled NFS Server on rhel-head</figcaption></figure><h4>Step 2: Configuring the Compute Nodes <strong>(rhel-node1, rhel-node2)</strong></h4><p>Install NFS client and SLURM daemon: <strong>sudo dnf install nfs-utils slurm slurm-slurmd -y</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lw2fC-m_M5jJZ0lBtaU7Og.png" /><figcaption>Mounted the /shared directory from the compute node</figcaption></figure><p>To make changes persistent after reboot, I added the string below to the /etc/fstab file, which is a configuration file on Linux.</p><p><strong>rhel-head:/home/jgalvez/shared /home/jgalvez/shared nfs defaults 0 0</strong></p><h4>Step 3: Configure SLURM on the rhel-head server</h4><p>Create a file called <strong>slurm.conf</strong> in /etc/slurm/ with the content below, and copy it to rhel-node1 and rhel-node2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4PZkjEQr0gxGfzKSO5QEUw.png" /></figure><p>Enable services on rhel-head: <strong>systemctl enable now slurmctld</strong></p><p>Enable services on each compute node: <strong>systemctl enable now slurmd</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*k8WAnddL0tkPUP-0yPG0Rw.png" /><figcaption>The SLURM daemon is now active and running</figcaption></figure><h4>Step 4: Submit a test SLURM job</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mZLS021Ek6EM6Mz8c4SdqA.png" /><figcaption>Created a simple script</figcaption></figure><p>From the rhel-head node, type <strong>sbatch job.sh</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*o6aCunZ4oR_WAhFe2UxENA.png" /><figcaption>Batch job running</figcaption></figure><p>Next, I checked the output of the batch job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*Hhc6hps4w5kcKFBsC8VEow.png" /><figcaption>Boom, Success</figcaption></figure><h4>Problems Found</h4><p><strong>1. Firewall Blocking Slurm Communication<br></strong>The first major issue I encountered was that srun jobs would hang or fail due to communication problems between the head node and the compute node (slurmd). Even though the slurmd service was running on the compute node, Slurm couldn’t launch tasks as expected.</p><p><strong>Solution:</strong><br>After some investigation, I realized the firewall was blocking necessary ports. Slurm communicates over specific ports, typically 6817–6819, which need to be opened for proper communication between nodes. I temporarily disabled the firewall on both the head and compute nodes to resolve the issue.</p><p><strong>2. Node State Showing as UNKNOWN</strong><br>The compute node (rhel-node1) was showing as UNKNOWN in the node status, which meant Slurm could not utilize it for job scheduling. This was likely caused by the communication issue mentioned above, preventing the Slurm controller from getting a status update from the compute node.</p><p><strong>Solution:</strong><br>Once I resolved the firewall issue, the node state updated automatically to IDLE. This showed that the communication between nodes had been restored.</p><p><strong>3. Output Files Not Found in /tmp</strong><br>I directed job output to /tmp/job_output_%j.txt, but I couldn’t find the output files. The issue was that /tmp is not shared across nodes, and it’s not guaranteed to be writable by the job runner in all environments.</p><p><strong>Solution:</strong><br>I switched to using the NFS shared directory that I configured earlier <strong>(/home/jgalvez/shared)</strong> to store output files. Using an NFS shared directory ensures job output is available even if the job is running on a compute node.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5d0ce03436b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leveling Up My Linux Skills: Automating Red Hat Linux with Ansible]]></title>
            <link>https://medium.com/@josue.galvez/leveling-up-my-red-hat-linux-skills-automating-red-hat-with-ansible-703dc192f0f3?source=rss-98f4576424c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/703dc192f0f3</guid>
            <dc:creator><![CDATA[Galvez Josue]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 17:51:12 GMT</pubDate>
            <atom:updated>2025-05-09T13:37:23.206Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been deepening my Linux skills as part of my learning journey, especially with Red Hat Enterprise Linux. Since I’m preparing for the RHCSA certification, I wanted to build a hands-on environment that goes beyond reading documentation. So I set up a lab using 2 virtual machines using Red Hat Linux on VMware Workstation Pro and decided to automate some common system tasks using Ansible.</p><p>This blog documents how I got everything running, plus a couple of simple but useful playbooks like installing NGINX and patching a system, using just a few lines of YAML code.</p><blockquote><strong>My Lab Setup:</strong><br>Controller Node:<strong> redhatserver</strong></blockquote><blockquote>Managed Node: <strong>redhatclient</strong></blockquote><h4>Step 1: Installing Ansible on the Controller Node<em> </em><strong><em>(redhatserver)</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*Dm83SrI0OH1EcInkRrmNjA.png" /><figcaption>Installing Ansible</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*9gvt7jIZK_DDhKBenGxvMg.png" /><figcaption>Confirm Ansible is installed correctly</figcaption></figure><h4>Step 2: SSH Key Setup for Remote Management</h4><p>Now I need to enable passwordless SSH authentication between systems. From the controller node, I generated an SSH key and copied the public key to the managed node. This allows secure, automated connections without needing a password, which is essential for Ansible to manage remote hosts. SSH must be enabled on the managed node, along with public key authentication for this to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IvoyZfAVzR7a81amcy3LAQ.png" /><figcaption>Generated Public and Private Key</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgUVPXcLoP5TwaiERNWTlw.png" /><figcaption>I copied the public key to the RedHatClient Host and tested the login — Success!</figcaption></figure><h4>Step 3: Ansible Inventory Configuration</h4><p>Ansible uses an inventory file <strong>/etc/ansible/hosts</strong> to define the hosts it manages. In this step, I am adding a new entry for the <strong>redhatclient</strong> host into the inventory file, so Ansible can manage it via SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydz2d3TiERVP5oxuYjSlwg.png" /><figcaption>Ansible Inventory File Entry</figcaption></figure><h4>Step 4: Testing the Connection</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MaAfUg-NtKKHJ4nU_i4Lww.png" /><figcaption>“Ping”: “Pong” means Ansible was able to contact and received a valid response from the remote host</figcaption></figure><h4>Step 5: Writing My First Real Playbooks</h4><p>I wanted to try something practical first, so I created a playbook to install and start <strong>NGINX</strong>.</p><p>From the command line type: <strong>sudo vim nginx_setup.yml</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*pAeAch-HpFQ3e8H25PIvVQ.png" /><figcaption>A playbook in Ansible is a configuration file written in YAML format. It defines a set of tasks that automate the management and configuration of systems.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nmYexv0MDf3KepMRAAg4lw.png" /><figcaption>Running the playbook: Success!</figcaption></figure><h3>System Patching</h3><p>Created a playbook called <strong><em>patch_system.yml</em></strong> to update the client. This step is an essential real-world maintenance task in Linux.</p><p>From the command line type: <strong>sudo vim patch_system.yml</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iwZzxmMHTsPcJmWx2rAVOA.png" /><figcaption>patch_system.yml playbook</figcaption></figure><p>Now run the playbook: <strong>ansible-playbook -i /etc/ansible/hosts patch_system.yml private-key=~/.ssh/ansible_key</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eHPMq21eX5Uk8YF62YaBGg.png" /><figcaption>SUCCESS!</figcaption></figure><h3>Final Thoughts</h3><ol><li>While setting up passwordless SSH between the <strong>RedHatServer</strong> and the R<strong>edHatClient</strong>, I ran into a small but important hurdle that taught me a lot about how ssh-copy-id works under the hood.</li></ol><p>Initially, when I tried to copy the SSH public key to the remote client, I received the error below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*aLZ3x-SbsXdZkitIWtV1Xg.png" /></figure><p>It turns out that the ssh-copy-id was expecting a default key like <strong>~/.ssh/id_rsa.pub</strong>, but I had created a custom key called <strong>ansible_key.pub</strong>.</p><p><strong>Fix:</strong> I had to explicitly point ssh-copy-id to the right public key:<br><strong>ssh-copy-id -i ~/.ssh/ansible_key.pub jgalvez@redhatclient</strong></p><p>2. Another small but critical issue was that <strong>public key authentication</strong> was disabled on the client side.</p><p><strong>Fix:</strong> I edited the /etc/ssh/sshd_config file and ensured <strong>PubkeyAuthentication</strong> was set to <strong>Yes</strong>, and restarted the SSH service.</p><h3>What I Learned</h3><ul><li>I gained hands-on experience writing basic Ansible playbooks to automate tasks across remote systems.</li><li>I set up SSH key-based authentication for <strong>Ansible</strong> communication using custom SSH keys.</li><li>I became more familiar with Red Hat Enterprise Linux, helping me build confidence for the RHCSA certification.</li><li>I learned how to run Ansible commands from a control node and target specific clients using Ansible playbooks.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=703dc192f0f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NOC Monitoring Project with Nagios, Splunk, Ubuntu, and Red Hat Linux]]></title>
            <link>https://medium.com/@josue.galvez/noc-monitoring-project-with-nagios-splunk-ubuntu-and-red-hat-linux-ff76e881bb5c?source=rss-98f4576424c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff76e881bb5c</guid>
            <dc:creator><![CDATA[Galvez Josue]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 15:23:43 GMT</pubDate>
            <atom:updated>2025-04-23T00:07:13.761Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ll walk you through a hands-on NOC project using Nagios Core and Splunk installed on an Ubuntu Server, and a simulated service (Apache) on a Red Hat Enterprise Linux (RHEL) VM. The Ubuntu machine acts as the monitoring/log aggregation server, while the RHEL machine is our monitored target.</p><h4>Project Goals</h4><ul><li>Install Nagios and Splunk on the Ubuntu Linux server.</li><li>Configure Apache on Linux Red Hat to simulate a real-world service.</li><li>Use NRPE to monitor the Red Hat server with Nagios.</li><li>Ingest Apache logs into Splunk for log analysis.</li></ul><h4>PART 1. Prepare Ubuntu Server (Monitoring Node)</h4><p>Step 1: Update &amp; Install Dependencies</p><p># Update package list<br>sudo apt update</p><p># Upgrade all packages to the latest version<br>sudo apt upgrade -y</p><p># Install dependencies for Nagios and Apache server.<br>sudo apt install -y wget curl unzip apache2 php gcc make libgd-dev libapache2-mod-php php-gd</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9SAkFep78AZPTpyX6ij55Q.png" /></figure><h4>Step 2: Add Nagios User</h4><p># Create the nagios user<br>sudo useradd nagios</p><p># Add a group for Nagios plugins<br>sudo groupadd nagplug</p><p># Add nagios user to the nagplug group<br>sudo usermod -a -G nagplug nagios</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*rp5e7dspIRseDT_J9Z0kLA.png" /></figure><h4>Step 3: Download &amp; Compile Nagios</h4><p># Download Nagios and extract it.<br>wget <a href="https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz">https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz</a></p><p># Extract the downloaded tarball<br>sudo tar -zxvf nagios-4.4.6.tar.gz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UBCBkOobRo1z5hgVEN7Wow.png" /></figure><p>Compile and install Nagios.</p><p># Enter the source directory<br>cd nagios-4.4.6</p><p># Configure build options<br>./configure — with-command-group=nagcmd</p><p># Compile Nagios<br>sudo make all</p><p># Install binaries<br>sudo make install</p><p># Install init script<br>sudo make install-init</p><p># Install command-mode permissions<br>sudo make install-commandmode</p><p># Install sample config files<br>sudo make install-config</p><p># Install Apache config for Nagios<br>sudo make install-webconf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rUhuTSJIZHEwIRRQ059pvg.png" /></figure><h4>Step 4: Configure Web Access</h4><p># Set a password for the nagiosadmin user (used for web access later)<br><strong>sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin</strong></p><h4>Step 5: Enable Apache &amp; Start Nagios</h4><p># Enable Apache rewrite and CGI modules<br><strong>sudo a2enmod rewrite cgi</strong></p><p># Restart Apache to apply changes<br><strong>sudo systemctl restart apache2</strong></p><p># Start Nagios<br><strong>sudo systemctl start nagios</strong></p><p># Enable Nagios at boot<br><strong>sudo systemctl enable nagios</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFK8HP7uPe_juTfzCCIz3g.png" /><figcaption>NAGIOS daemon is running now</figcaption></figure><h4>Step 6: Access Nagios via a Web browser http://ubuntu/nagios/</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*6qTKan10weT8iLdwyspY4g.png" /><figcaption>Boom. Success</figcaption></figure><h4>PART 2: Install Splunk on Ubuntu Server</h4><p># Go to the Splunk website, create an account, and download the Splunk Enterprise 9.4.1 free version.</p><p><strong>wget -O splunk-9.4.1-e3bdab203ac8-linux-amd64.deb “</strong><a href="https://download.splunk.com/products/splunk/releases/9.4.1/linux/splunk-9.4.1-e3bdab203ac8-linux-amd64.deb"><strong>https://download.splunk.com/products/splunk/releases/9.4.1/linux/splunk-9.4.1-e3bdab203ac8-linux-amd64.deb</strong></a><strong>&quot;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L96JvSyQZjfTzZ-mVBJqIg.png" /><figcaption>Download the debian package for Ubuntu</figcaption></figure><p># Now, install the Splunk .deb package manually<br><strong>sudo dpkg -i splunk-9.4.1-e3bdab203ac8-linux-amd64.deb</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*O5ozNeyJJlmiOjk5je2prg.png" /></figure><p>Step 2: Next, start and enable Splunk at boot time</p><p># Start Splunk for first time, accept license<br><strong>sudo /opt/splunk/bin/splunk start — accept-license</strong></p><p># Enable Splunk at boot<br><strong>sudo /opt/splunk/bin/splunk enable boot-start</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*XPcTCMBeOIC_Nh6dQ6tPmg.png" /><figcaption>Splunkd service is running and can be accessed at http://Ubuntu:8000</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBfuvOQgYGoTUcBU9_Ceeg.png" /><figcaption>SUCCESS.</figcaption></figure><h4>PART 3: Set Up RedHat Linux (Monitored Node)</h4><p>Step 1: # Install Apache web server<br><strong>sudo dnf install httpd -y</strong></p><p># Start and enable the httpd service<br><strong>sudo systemctl start httpd<br>sudo systemctl enable httpd</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*tHy2vm8Bpt5dDVLeXKJ3cQ.png" /></figure><p>Step 2: Install the NRPE service and Plugins</p><p># Installs the “epel-release” repo so you can access community-supported packages like nrpe and nagios-plugins.<br><strong>sudo dnf install epel-release -y</strong></p><p># Install NRPE and Nagios plugins<br><strong>sudo dnf install nrpe nagios-plugins-load nagios-plugins-disk nagios-plugins-procs nagios-plugins-users -y</strong></p><p># Start and enable NRPE service<br><strong>sudo systemctl start nrpe</strong><br><strong>sudo systemctl enable nrpe</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*I-aH1FR0UOJY-bMn_tbdbw.png" /></figure><p># Allow Nagios server IP in NRPE config<br><strong>sudo vi /etc/nagios/nrpe.cfg</strong><br># Add to the allowed_hosts line: allowed_hosts=127.0.0.1,&lt;Ubuntu-IP&gt;</p><p># Restart NRPE<br>sudo systemctl restart nrpe</p><h4>PART 4: Configure Nagios to Monitor the Red Hat Server</h4><p># Create a config file from the Ubuntu Server to monitor the RedHat server.<br><strong>sudo vi /usr/local/nagios/etc/servers/rhel.cfg</strong></p><p>define host{<br> use linux-server<br> host_name redhat01<br> alias RHEL Web Server<br> address 192.168.1.116<br> max_check_attempts 5<br> check_period 24x7<br> notification_interval 30<br> notification_period 24x7<br>}</p><p>define service{<br> use generic-service<br> host_name redhat01<br> service_description HTTP<br> check_command check_http<br>}</p><p>#Download, extract, and install Nagios Plugins</p><p><strong>wget </strong><a href="https://nagios-plugins.org/download/nagios-plugins-2.4.9.tar.gz"><strong>https://nagios-plugins.org/download/nagios-plugins-2.4.9.tar.gz</strong></a><br><strong>tar -xzf nagios-plugins-2.4.9.tar.gz</strong></p><p># Restart Nagios to load the new config<br><strong>sudo systemctl restart nagios</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9-UxrxHoEdGVWQY-93WdPg.png" /><figcaption>It Worked :)</figcaption></figure><h4>PART 5: Send Apache Logs from RHEL to Splunk</h4><p>Step 1: On the Splunk web interface from the UBUNTU SERVER, create a <strong>TCP</strong> Listener</p><p>Go to Settings &gt; Data Inputs &gt; TCP and add a new input on port 9997</p><p>Step 2: On Red Hat Server, Send Logs via Syslog</p><p># Install rsyslog (if not already installed)<br><strong>sudo dnf install rsyslog -y</strong></p><p># Edit the rsyslog config to send logs to the Splunk server and add this line *.*@@192.168.1.111:9997<br><strong>sudo vi /etc/rsyslog.d/apache.conf</strong></p><p># Restart rsyslog<br><strong>sudo systemctl restart rsyslog</strong></p><p>Now your Apache logs should appear in Splunk’s search interface!<br><strong>Try searching: index=main source=”/var/log/httpd/access_log”</strong></p><h4>Problems Found</h4><ol><li><strong>Disk Space</strong></li></ol><p>When I first set up my Ubuntu server to run Splunk and Nagios, I made a critical but common mistake: I underestimated how much disk space I’d need and allocated minimal storage.</p><p>Everything seemed fine at first until I logged into the Splunk web interface and got hit with this message:</p><p>“Search not executed: The minimum free disk space (5000MB) reached for /opt/splunk/var/run/splunk/dispatch.”</p><p>That’s when I realized Splunk needs at least 5GB of free space just for search operations. And guess what? I didn’t leave enough headroom on /opt the directory where Splunk lives.</p><p>2. <strong>Firewall Issues</strong></p><p>The Red Hat server had a firewall configuration issue that blocked incoming NRPE requests from the Nagios server, which was running on Ubuntu. This prevented successful communication for service checks. Specifically, firewalld on Red Hat was blocking port 5666/tcp, which is required for the NRPE plugin to receive and respond to remote checks.</p><p><strong><em>Solution:</em></strong><br>To allow NRPE traffic from the Nagios server, I run the following commands on the Red Hat server:<br><strong>sudo firewall-cmd — permanent — add-port=5666/tcp</strong><br><strong>sudo firewall-cmd — reload</strong><br>This change enabled the Red Hat server to accept NRPE requests, restoring full monitoring functionality from the Ubuntu-based Nagios server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff76e881bb5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Set Up SSH and Keyless Authentication on Red Hat Linux]]></title>
            <link>https://medium.com/@josue.galvez/how-i-set-up-ssh-authentication-for-my-red-hat-linux-server-32f2c66c0ca0?source=rss-98f4576424c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/32f2c66c0ca0</guid>
            <dc:creator><![CDATA[Galvez Josue]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 21:51:47 GMT</pubDate>
            <atom:updated>2025-06-14T17:04:18.671Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*n6ZH2eRO-oAgyY2b1im7Qg.png" /></figure><blockquote>“SSHing into my first RHEL machine felt like unlocking a secret level in a video game. It was the moment I stopped being just a user and started feeling like an admin.”</blockquote><p>As someone who loves tinkering with Linux systems and learning by doing, setting up SSH access to my Red Hat Enterprise Linux (RHEL) virtual machine felt like a rite of passage. I’d been using RHEL on a local VM for a while, but the real freedom came when I could access it remotely from my Windows machine anytime, anywhere, like a true sysadmin.</p><p>In this post, I’ll walk you through how I set up secure remote access via SSH on a RHEL virtual machine (VM), the gotchas I encountered, and what I learned along the way.</p><h4>1. Installing the SSH Server.</h4><p>First, I needed to install and start the OpenSSH server.</p><p># Install the OpenSSH server package.<br>sudo dnf install openssh-server</p><p># Starts the SSH daemon or service (sshd).<br>sudo systemctl start sshd</p><p># Enable the SSH service to start automatically on system boot.<br>sudo systemctl enable sshd.</p><p># Confirm the service is running.<br>sudo systemctl status sshd</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TBUp1EPAuJ4tAx_zbGQd3g.png" /></figure><h4>2. Configuring the Firewall</h4><p>SSH was initially blocked, and I didn’t realize it until I spent 5 minutes trying to connect. A quick fix with firewalld fixed the issue.</p><p># Add the SSH service to the allowed list in firewalld<br>sudo firewall-cmd — permanent — add-service=ssh</p><p># Reload the firewall to apply the new configuration<br>sudo firewall-cmd — reload</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*CHRaAeiGQZO396byYeKDUw.png" /><figcaption>In this case, I already had the SSH daemon enabled</figcaption></figure><h4>3. SSHing from Windows Host.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*3yI_M15rzBNT0TLDg3_1yA.png" /><figcaption>Boom. Success</figcaption></figure><h4>4. SSH Key-Based Authentication</h4><p>This step made logins faster and more secure.</p><p>This creates the id_rsa (private key) and id_rsa.pub (public key) on my PC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*Nu1fgxeQOVpugA3nXSEThA.png" /><figcaption>ssh-keygen</figcaption></figure><p>Now copy the public key to the remote host for passwordless login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CumIyuLAnJg3HIzRQE4o4g.png" /><figcaption>ssh-copy-id jgalvez@redhat01</figcaption></figure><h4>5. Disable Password Authentication</h4><p>To improve security, I disabled password logins so only SSH keys work:</p><p># Edit the SSH config file<br>sudo vim /etc/ssh/sshd_config</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*bL5fuaowyhOt-9n6g0RDaA.png" /><figcaption>Find this line and change it to: PasswordAuthentication no</figcaption></figure><p># Then restart the SSH daemon<br>sudo systemctl restart sshd<br>Now, only devices with the SSH key can log in.</p><h3>Problems Found</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*OJKMNGSNr2H482QvQcYCNQ.png" /><figcaption>When trying to SSH for the first time, I kept getting “Permission Denied”</figcaption></figure><p><em>SSH Key Saved to Wrong User Directory</em><br>During the initial ssh-keygen attempt, the generated key pair was saved to /home/jgalvez/.ssh instead of the expected C:/Users/galve/.ssh on the Windows host. This mismatch likely occurred because the HOME environment variable was pointing to a different user path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*7ny7nZg19vz-dpADe8BvbA.png" /><figcaption>Type -1 means: your private key doesn’t exist</figcaption></figure><p><em>PubkeyAuthentication Disabled on the remote host</em><br>The sshd_config file on the Red Hat Enterprise Linux 9 system had “PubkeyAuthentication set to no”. This prevented the SSH daemon from accepting key-based logins, regardless of whether a valid key was present.</p><h3>What I Learned</h3><p>Always verify where SSH keys are saved, especially when working across different systems.</p><p>SSH authentication issues can stem from misconfigured sshd_config, incorrect key locations, or permissions.</p><h3>Wrapping Up</h3><p>After troubleshooting SSH key-based login issues, I resolved the problem by generating a new RSA key pair, correcting the file paths, and ensuring the SSH service was properly configured. Passwordless login is now working as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*nJXJs3HRRRBOeCo4tyTP8Q.png" /><figcaption>SUCCESS!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32f2c66c0ca0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying and Troubleshooting a Django Application on Linux]]></title>
            <link>https://medium.com/@josue.galvez/troubleshooting-and-deploying-a-two-tier-django-app-on-linux-334d1b3f484f?source=rss-98f4576424c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/334d1b3f484f</guid>
            <dc:creator><![CDATA[Galvez Josue]]></dc:creator>
            <pubDate>Wed, 20 Nov 2024 17:19:54 GMT</pubDate>
            <atom:updated>2025-06-16T19:41:17.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*gT-qpr4t9k96TvIPPegpQQ.png" /></figure><p><strong>Introduction:</strong><br>Deploying a <strong>two-tier application</strong> can be challenging, especially when transitioning from a local development environment to dedicated servers. In this blog, I documented the troubleshooting steps I took to help my co-worker Bob prepare his application for a client presentation. The application functions perfectly on his laptop. However, it is not working after transferring the code to the development server.</p><blockquote><strong>A two-tier architecture</strong> typically separates the presentation layer (<strong>front end</strong>) from the data access and business logic layer (<strong>back end</strong>).</blockquote><ul><li>The Web server (front-end) is hosted on <strong>devapp01</strong></li><li>The Database server (back-end) is hosted on <strong>devdb01</strong></li></ul><h4>Task 1: Copying code to the Web Server</h4><p>I copied the file caleston-code.tar.gz from Bob’s laptop to the web server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*dgDf8bEaOHkbWhWVbuQz7w.png" /></figure><p>From the web server, I extracted the contents of the <strong>caleston-code.tar.gz</strong> archive into the <strong>/opt/ directory</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*2aBXIC-vhqM7kvFunuvz9w.png" /></figure><p><strong>tar:</strong> Tool used for creating and extracting archives.<br><strong>-C /opt/:</strong> Tells tar to change to the <strong>/opt/ directory</strong> before extracting the contents of <strong>caleston-code.tar.gz</strong>.<br><strong>x:</strong> Extracts the archive.<br><strong>v:</strong> Verbosely list the files being extracted.<br><strong>f:</strong> Specifies the file to extract, in this case, <strong>caleston-code.tar.gz</strong>.</p><p>Confirm code was extracted to <strong>/opt/caleston-code/mercuryProject/</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*Y9ffq-5aV3tycPNCExRcmg.png" /></figure><h4><strong>Task 2:</strong> From the <strong>database server,</strong> add the entry below to the end of pg_hba.conf file to allow the web server to connect to the database</h4><p><strong><em>host all all 0.0.0.0/0 md5</em></strong></p><p>vi /etc/postgresql/10/main/pg_hba.conf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*Q3NctFUztTUezMSsjRgwcQ.png" /><figcaption>Added entry to pg_hba.conf file</figcaption></figure><h4>Task 3: The Postgres database has already been installed and needs to be ensured it is running</h4><p><strong><em>sudo systemctl start postgresql</em></strong></p><p><strong>Systemctl:</strong> This command interacts with the systemd system.<br><strong>Start:</strong> Tells <strong>systemctl</strong> to start the PostgreSQL service.<br><strong>PostgreSQL:</strong> The name of the service.</p><p><strong><em>sudo systemctl status postgresql</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*TwM2rJGsJfgmldQNSGbVJg.png" /></figure><h4><strong>Task 4: Check what port Postgres is running on</strong></h4><p><em>netstat -natulp | grep postgres | grep LISTEN</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*NmfoQfVsLmKt-kcEhVj_0w.png" /><figcaption>postgres is running on port 5432</figcaption></figure><h4><strong>Task 5: </strong>From the web server, start the web application by navigating to <strong><em>/opt/calestoncode/mercuryProject</em></strong></h4><p><strong><em>Run: </em></strong>python3 manage.py runserver 0.0.0.0:8000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*mKLivpuuVtozPufIqLJxpg.png" /><figcaption>The Application failed to load. Why?</figcaption></figure><p><strong><em>“Connection refused DB on 127.0.01 on port 5433&quot;</em></strong></p><p>This explains why everything is functioning properly on Bob’s laptop but not on the development servers. It appears that he is using the incorrect port and host in the settings.py file.</p><h4><strong>Task 6:</strong> Use Vim to update ‘HOST’ and ‘Port’ strings</h4><p>vim /opt/caleston-code/mercuryProject/mercury/settings.py</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*dXrjOGdAH6dtV-dAUxSL6Q.png" /><figcaption>The HOST and PORT sections have been updated</figcaption></figure><h4><strong>Task 7:</strong> Change ownership of all files <em>to user </em><strong><em>mercury</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*q7p0p_n_X7TG5swOderhEQ.png" /></figure><h4><strong>Task 8:</strong> Restart application on the web server</h4><ol><li>Navigate to <strong>/opt/caleston-code</strong><em> </em>and run<em> </em><strong><em>source</em></strong> <strong><em>venv/bin/activate</em></strong> to activate the Python virtual environment you’ll see (venv) in the prompt.</li><li>Change the directory to <strong>/opt/caleston-code/mercuryProject</strong> and run <strong><em>python3 manage.py migrate. </em></strong>This will<strong><em> </em></strong>apply database migrations, creating or updating database tables to match the Django app’s models.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*K3PckygM0uoIlc3znw1QWw.png" /></figure><p>3. Run the command <strong><em>python3 manage.py runserver 0.0.0.0:8000</em></strong> to start the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dFsLRts9YtSrv0ZeMN9ahg.png" /><figcaption>SUCCESS</figcaption></figure><h3><strong>Conclusion:</strong></h3><p>This project highlighted the challenges of deploying a <strong>two-tier</strong> Django application and the troubleshooting required to ensure functionality.</p><p><strong>Key issues encountered included:</strong></p><ul><li>Incorrect database configurations in the application, such as using the wrong host (<strong>localhost</strong> instead of <strong>devdb01</strong>) and port (<strong>5433</strong> instead of <strong>5432</strong>).</li><li>Missing permissions in the <strong>pg_hba.conf </strong>file on the database server, which required modification to allow external connections.</li><li>Overcoming application initialization errors by ensuring the correct virtual environment was activated and database migrations were applied.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=334d1b3f484f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Permissions: Managing Users, Groups, and Access]]></title>
            <link>https://medium.com/@josue.galvez/linux-permissions-managing-users-groups-and-access-4cf9633f9668?source=rss-98f4576424c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cf9633f9668</guid>
            <category><![CDATA[linuxworld]]></category>
            <category><![CDATA[linux-security]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[centos-stream]]></category>
            <dc:creator><![CDATA[Galvez Josue]]></dc:creator>
            <pubDate>Fri, 15 Nov 2024 22:38:27 GMT</pubDate>
            <atom:updated>2024-11-15T22:38:27.948Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*lgFrFChwnIpP_gI7Df17FQ.png" /></figure><p><strong>Introduction</strong><br>In this tutorial, I’ll walk you through a scenario where a growing software company needs to manage its IT resources efficiently and securely in a Linux environment. I’ll create users, groups, directories, and files and set up permissions to ensure only authorized users have access to certain resources.</p><p><strong>The Task</strong><br>Our company needs to ensure the confidentiality and integrity of its resources by correctly setting user and group permissions. I’ll demonstrate how to create directories, groups, and users and assign appropriate permissions using Linux commands. This will help prove that permissions work and that each user has the correct access.</p><p><strong>Step-by-Step Guide</strong></p><p><strong>Step 1: Create Directories for Teams</strong><br>Let’s start by creating three new directories for different departments in our organization: Research, Sales, and Marketing.</p><p><em>cd ~ # Move to the home directory</em></p><p># Create directories<em><br>mkdir Research Sales Marketing</em></p><p># Create dummy files in each directory<em><br>touch Research/file1.txt Research/file2.txt Research/file3.txt<br>touch Sales/file1.txt Sales/file2.txt Sales/file3.txt<br>touch Marketing/file1.txt Marketing/file2.txt Marketing/file3.txt</em></p><p># Verify the files were created<em><br>ls -l Research Sales Marketing</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*OKOQZ8OVfPxRnxM1sr3y0Q.png" /><figcaption>This step demonstrates how to organize directories and files for each department.</figcaption></figure><p><strong>Step 2: Create Groups for Each Department</strong><br>Next, we will create groups for each department so that only the members of the specific department can access their respective directories.</p><p># Create groups for each department<em><br>sudo groupadd research_group<br>sudo groupadd sales_group<br>sudo groupadd marketing_group</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*FQxe4AIhaL9ZsrZnmsVxLA.png" /></figure><p># Verify that the groups were created<br><em>getent group research_group<br>getent group sales_group<br>getent group marketing_group</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*Ck9RpVr7L-BxlwvCdISSLw.png" /><figcaption>This ensures that the appropriate groups are created for each department.</figcaption></figure><p><strong>Step 3: Assign Group Ownership to Directories</strong><br>Now, let’s assign each directory to its respective group. This will ensure that only users in a specific group can access the directory.</p><p># Assign group ownership<br><em>sudo chown :research_group Research<br>sudo chown :sales_group Sales<br>sudo chown :marketing_group Marketing</em></p><p># Verify the ownership<br><em>ls -ld Research Sales Marketing</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*JKnPc743AGeUnGJfDepEYw.png" /><figcaption>Each directory is now owned by its respective group.</figcaption></figure><p><strong>Step 4: Set Permissions for the Directories</strong><br>We want to ensure that only the group members can access and modify the files within their directories, while others should be restricted.</p><p># Set directory permissions<br><em>sudo chmod 770 Research<br>sudo chmod 770 Sales<br>sudo chmod 770 Marketing</em></p><p># Verify the permissions<br><em>ls -ld Research Sales Marketing</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*517oFqkzByuPOhse_sRiqw.png" /><figcaption>With 770 permissions, the group members have full access (read, write, execute), while others have no access.</figcaption></figure><p>The <strong>chmod 770</strong> command in Linux sets the permissions for a file or directory as follows:</p><p>Owner (first digit 7): Read, write, and execute permissions (rwx).<br>Group (second digit 7): Read, write, and execute permissions (rwx).<br>Others (third digit 0): No permissions ( — -).</p><p><strong>In numerical terms:</strong></p><p>7 = Read (4) + Write (2) + Execute (1) = 7<br>0 = No permissions<br>So, <strong>chmod 770</strong> gives full permissions to the owner and group, while denying any access to others.</p><p><strong>Step 5: Create Users and Assign to Groups</strong><br>Next, I’ll create users and assign them to the appropriate groups. For each department, I’ll add one user.</p><p># Create users and add them to their respective groups<br><em>sudo useradd -m -G research_group josh<br>sudo useradd -m -G sales_group jane<br>sudo useradd -m -G marketing_group alex</em></p><p># Set passwords for users<br>sudo passwd josh<br>sudo passwd jane<br>sudo passwd alex</p><p># Verify user creation<br><em>getent passwd john_doe<br>getent passwd jane_smith<br>getent passwd alex_johnson</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*DyxJ48EUkvs3MMnkzOZUcA.png" /><figcaption>Created the users Josh, Jane, and Alex, and added them to their respective department groups.</figcaption></figure><p><strong>Step 6: Test User Access</strong><br>To ensure everything is set up correctly, let’s switch users and test access.</p><ol><li>Log in as <strong>josh</strong>: <em>su — josh</em></li><li>Try accessing the directories:</li></ol><p># Check access to own directory (should have full access)<br><em>cd Research<br>ls -l</em></p><p># Check access to other directories (should be denied)<br><em>cd Sales # This should fail with “Permission denied”<br>cd Marketing # This should fail with “Permission denied”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*4AXWQXoqWFZsoRqj3bQpnA.png" /><figcaption>This verifies that each user only has access to the directory assigned to their group.</figcaption></figure><p>3. Repeat the process for users Jane and Alex checking access to their respective directories.</p><p><em>su — jane</em><br><em>cd Sales</em> # Should have access<br><em>cd Research</em> # Should be denied<br><em>cd Marketing</em> # Should be denied</p><p><em>su — alex</em><br><em>cd Marketing</em> # Should have access<br><em>cd Research</em> # Should be denied<br><em>cd Sales</em> # Should be denied</p><p><strong>Conclusion</strong><br>This project demonstrates how to manage IT resources securely and efficiently using <strong>Linux.</strong> By creating groups, users, and directories, and assigning appropriate permissions, we ensure that only authorized users can access sensitive resources. This process is fundamental for maintaining the confidentiality, availability, and integrity of your company’s data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cf9633f9668" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>