<?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"><channel><title><![CDATA[Day 11 – File Ownership in Linux]]></title><description><![CDATA[Day 11 – File Ownership in Linux]]></description><link>https://day-11-file-ownership-in-linux.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 02:03:22 GMT</lastBuildDate><atom:link href="https://day-11-file-ownership-in-linux.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[🐧 Day 11 – Understanding File Ownership in Linux (chown & chgrp)]]></title><description><![CDATA[Today I learned something that made me realize Linux is built for multi-user systems. Files are not just about read/write/execute permissions — they also…]]></description><link>https://day-11-file-ownership-in-linux.hashnode.dev/day-11-understanding-file-ownership-in-linux-chown-and-chgrp</link><guid isPermaLink="true">https://day-11-file-ownership-in-linux.hashnode.dev/day-11-understanding-file-ownership-in-linux-chown-and-chgrp</guid><category><![CDATA[Devops]]></category><category><![CDATA[devopslearning]]></category><category><![CDATA[linux for beginners]]></category><dc:creator><![CDATA[Divyat Agrawal]]></dc:creator><pubDate>Mon, 02 Feb 2026 18:30:00 GMT</pubDate><content:encoded><![CDATA[<p>Today I learned something that made me realize Linux is built for <strong>multi-user systems</strong>. Files are not just about read/write/execute permissions — they also belong to <strong>specific users and groups</strong>.</p>
<p>This is super important in DevOps because applications, logs, and deployments all depend on <strong>correct ownership</strong>.</p>
<p>Let’s break it down step by step.</p>
<hr />
<h2 id="heading-task-1-understanding-file-ownership">📌 Task 1: Understanding File Ownership</h2>
<p><strong>Goal of this task:</strong><br />Before changing ownership, I first needed to understand how Linux currently assigns owners and groups to files.</p>
<p>I started by checking file ownership in my home directory:</p>
<pre><code class="lang-plaintext">ls -l
</code></pre>
<p>Sample output:</p>
<pre><code class="lang-plaintext">-rw-r--r-- 1 divyat divyat   0 Feb 6 10:00 devops.txt
-rw-r--r-- 1 divyat divyat  32 Feb 6 10:05 notes.txt
</code></pre>
<h3 id="heading-format-breakdown">Format Breakdown</h3>
<pre><code class="lang-plaintext">-rw-r--r-- 1 owner group size date filename
</code></pre>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Column</td><td>Meaning</td></tr>
</thead>
<tbody>
<tr>
<td>owner</td><td>The user who owns the file</td></tr>
<tr>
<td>group</td><td>The group that owns the file</td></tr>
</tbody>
</table>
</div><h3 id="heading-owner-vs-group">🤔 Owner vs Group</h3>
<ul>
<li><p><strong>Owner</strong> → The main user who controls the file</p>
</li>
<li><p><strong>Group</strong> → A set of users who share access</p>
</li>
</ul>
<p>Example:<br />If a file belongs to user <code>divyat</code> and group <code>dev-team</code>, then:</p>
<ul>
<li><p>Only <strong>divyat</strong> is the owner</p>
</li>
<li><p>All users inside <strong>dev-team group</strong> get group permissions</p>
</li>
</ul>
<hr />
<h2 id="heading-task-2-basic-chown-operations-change-owner">🛠️ Task 2: Basic <code>chown</code> Operations (Change Owner)</h2>
<p><strong>Goal of this task:</strong><br />Learn how to transfer file ownership from one user to another.</p>
<h3 id="heading-1-create-a-file">1️⃣ Create a file</h3>
<pre><code class="lang-plaintext">touch devops-file.txt
</code></pre>
<p>Check owner:</p>
<pre><code class="lang-plaintext">ls -l devops-file.txt
</code></pre>
<p>Output:</p>
<pre><code class="lang-plaintext">-rw-r--r-- 1 divyat divyat 0 devops-file.txt
</code></pre>
<p>Both owner and group are <code>divyat</code>.</p>
<hr />
<h3 id="heading-2-create-new-users-if-not-present">2️⃣ Create new users (if not present)</h3>
<pre><code class="lang-plaintext">sudo useradd tokyo
sudo useradd berlin
</code></pre>
<hr />
<h3 id="heading-3-change-owner-to-tokyo">3️⃣ Change owner to <strong>tokyo</strong></h3>
<pre><code class="lang-plaintext">sudo chown tokyo devops-file.txt
</code></pre>
<p>Verify:</p>
<pre><code class="lang-plaintext">ls -l devops-file.txt
</code></pre>
<p>Now:</p>
<pre><code class="lang-plaintext">-rw-r--r-- 1 tokyo divyat 0 devops-file.txt
</code></pre>
<p>Owner changed ✅</p>
<hr />
<h3 id="heading-4-change-owner-to-berlin">4️⃣ Change owner to <strong>berlin</strong></h3>
<pre><code class="lang-plaintext">sudo chown berlin devops-file.txt
</code></pre>
<p>Now file owner becomes <strong>berlin</strong>.</p>
<hr />
<h2 id="heading-task-3-basic-chgrp-operations-change-group">👥 Task 3: Basic <code>chgrp</code> Operations (Change Group)</h2>
<p><strong>Goal of this task:</strong><br />Understand how to assign files to a specific team by changing their group ownership.</p>
<h3 id="heading-1-create-file">1️⃣ Create file</h3>
<pre><code class="lang-plaintext">touch team-notes.txt
</code></pre>
<p>Check group:</p>
<pre><code class="lang-plaintext">ls -l team-notes.txt
</code></pre>
<hr />
<h3 id="heading-2-create-group">2️⃣ Create group</h3>
<pre><code class="lang-plaintext">sudo groupadd heist-team
</code></pre>
<hr />
<h3 id="heading-3-change-file-group">3️⃣ Change file group</h3>
<pre><code class="lang-plaintext">sudo chgrp heist-team team-notes.txt
</code></pre>
<p>Verify:</p>
<pre><code class="lang-plaintext">ls -l team-notes.txt
</code></pre>
<p>Now group changes from your default group to <strong>heist-team</strong>.</p>
<hr />
<h2 id="heading-task-4-change-owner-and-group-together">🔄 Task 4: Change Owner AND Group Together</h2>
<p><strong>Goal of this task:</strong><br />Learn how to assign both a new user and a new group in a single command.</p>
<h3 id="heading-1-create-file-1">1️⃣ Create file</h3>
<pre><code class="lang-plaintext">touch project-config.yaml
</code></pre>
<h3 id="heading-2-change-owner-to-professor-and-group-to-heist-team">2️⃣ Change owner to <strong>professor</strong> and group to <strong>heist-team</strong></h3>
<p>First create user:</p>
<pre><code class="lang-plaintext">sudo useradd professor
</code></pre>
<p>Then run:</p>
<pre><code class="lang-plaintext">sudo chown professor:heist-team project-config.yaml
</code></pre>
<p>Verify:</p>
<pre><code class="lang-plaintext">ls -l project-config.yaml
</code></pre>
<hr />
<h3 id="heading-3-change-ownership-of-a-directory">3️⃣ Change ownership of a directory</h3>
<pre><code class="lang-plaintext">mkdir app-logs
sudo chown berlin:heist-team app-logs
</code></pre>
<p>Now the directory belongs to <strong>berlin</strong> and group <strong>heist-team</strong>.</p>
<hr />
<h2 id="heading-task-5-recursive-ownership-change">🌳 Task 5: Recursive Ownership Change</h2>
<p><strong>Goal of this task:</strong><br />Apply ownership changes to an entire project folder and everything inside it.</p>
<h3 id="heading-1-create-directory-structure">1️⃣ Create directory structure</h3>
<pre><code class="lang-plaintext">mkdir -p heist-project/vault
mkdir -p heist-project/plans
touch heist-project/vault/gold.txt
touch heist-project/plans/strategy.conf
</code></pre>
<hr />
<h3 id="heading-2-create-group-1">2️⃣ Create group</h3>
<pre><code class="lang-plaintext">sudo groupadd planners
</code></pre>
<hr />
<h3 id="heading-3-change-ownership-recursively">3️⃣ Change ownership recursively</h3>
<pre><code class="lang-plaintext">sudo chown -R professor:planners heist-project/
</code></pre>
<h3 id="heading-what-does-r-mean">What does <code>-R</code> mean?</h3>
<p><code>-R</code> = Recursive<br />It changes ownership for:</p>
<ul>
<li><p>The folder</p>
</li>
<li><p>All subfolders</p>
</li>
<li><p>All files inside</p>
</li>
</ul>
<hr />
<h3 id="heading-4-verify">4️⃣ Verify</h3>
<pre><code class="lang-plaintext">ls -lR heist-project/
</code></pre>
<p>You’ll see <strong>every file and folder</strong> now belongs to <code>professor</code> and group <code>planners</code>.</p>
<hr />
<h2 id="heading-task-6-practice-challenge">🎯 Task 6: Practice Challenge</h2>
<p><strong>Goal of this task:</strong><br />Simulate a real DevOps environment where different team members and teams own different project files.</p>
<h3 id="heading-1-create-users">1️⃣ Create users</h3>
<pre><code class="lang-plaintext">sudo useradd tokyo
sudo useradd berlin
sudo useradd nairobi
</code></pre>
<h3 id="heading-2-create-groups">2️⃣ Create groups</h3>
<pre><code class="lang-plaintext">sudo groupadd vault-team
sudo groupadd tech-team
</code></pre>
<hr />
<h3 id="heading-3-create-directory-and-files">3️⃣ Create directory and files</h3>
<pre><code class="lang-plaintext">mkdir bank-heist
touch bank-heist/access-codes.txt
touch bank-heist/blueprints.pdf
touch bank-heist/escape-plan.txt
</code></pre>
<hr />
<h3 id="heading-4-assign-ownership">4️⃣ Assign ownership</h3>
<pre><code class="lang-plaintext">sudo chown tokyo:vault-team bank-heist/access-codes.txt
sudo chown berlin:tech-team bank-heist/blueprints.pdf
sudo chown nairobi:vault-team bank-heist/escape-plan.txt
</code></pre>
<hr />
<h3 id="heading-5-verify">5️⃣ Verify</h3>
<pre><code class="lang-plaintext">ls -l bank-heist/
</code></pre>
<p>Now each file has <strong>different owner and group</strong> — just like real production systems where different teams handle different resources.</p>
<hr />
<h2 id="heading-what-i-learned-today">🧠 What I Learned Today</h2>
<p>1️⃣ Linux files belong to <strong>users and groups</strong>, not just permissions<br />2️⃣ <code>chown</code> changes owner, <code>chgrp</code> changes group<br />3️⃣ <code>chown owner:group</code> can change both at once<br />4️⃣ <code>-R</code> is powerful — it updates entire directory trees<br />5️⃣ Ownership is critical in DevOps for apps, logs, and deployments</p>
<hr />
<h2 id="heading-why-this-matters-in-devops">🚀 Why This Matters in DevOps</h2>
<p>In real environments:</p>
<ul>
<li><p>Web apps run as specific users</p>
</li>
<li><p>Logs must belong to logging services</p>
</li>
<li><p>Teams share folders using groups</p>
</li>
<li><p>Wrong ownership = <strong>application crashes</strong></p>
</li>
</ul>
<p>Learning this today made Linux feel more like a <strong>real production system</strong> rather than just a practice machine.</p>
]]></content:encoded></item></channel></rss>