<?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 TechNora on Medium]]></title>
        <description><![CDATA[Stories by TechNora on Medium]]></description>
        <link>https://medium.com/@Mnurp?source=rss-56ee75d97e4d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*79Q1ZltAo5o9RfLVPQqjkg.jpeg</url>
            <title>Stories by TechNora on Medium</title>
            <link>https://medium.com/@Mnurp?source=rss-56ee75d97e4d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:16:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Mnurp/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[Understanding Linux File Permissions and Ownership]]></title>
            <link>https://medium.com/@Mnurp/understanding-linux-file-permissions-and-ownership-a-comprehensive-guide-93842216e94e?source=rss-56ee75d97e4d------2</link>
            <guid isPermaLink="false">https://medium.com/p/93842216e94e</guid>
            <category><![CDATA[linux-system]]></category>
            <category><![CDATA[linux-security]]></category>
            <category><![CDATA[suid-bit]]></category>
            <category><![CDATA[linux-permission]]></category>
            <category><![CDATA[linux-commands]]></category>
            <dc:creator><![CDATA[TechNora]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 12:33:51 GMT</pubDate>
            <atom:updated>2026-09-22T13:40:47.264Z</atom:updated>
            <content:encoded><![CDATA[<p>In Linux operating systems, controlling access to files and directories is a foundational security mechanism. Permissions determine who can view, modify, or execute files, while ownership dictates which user and group control those files. This guide covers how permissions work, how they apply to different user levels, and how to modify them using the command line.</p><h3>1. Core Concepts: Permissions as Access Keys</h3><p>In Linux, permissions act like keys distributed to specific individuals and teams within an organization. Not every key fits every door, which ensures that users cannot access files or directories they shouldn’t. Permissions define clear access levels, allowing individuals and groups to reach contents only as much as their tasks require. In this way, sensitive system and user data stays safe.</p><p>Every file and directory in Linux is connected to two main entities:</p><ul><li><strong>User Owner:</strong> The individual account that controls the file.</li><li><strong>Group Owner:</strong> A collective group that shares access to the file.</li></ul><p>Whenever you generate a new file or directory, Linux automatically assigns you as the user owner and links the item to your primary user group. You can think of this like creating a document at work: by default, it is saved under your personal account and shared with your immediate department so your colleagues can collaborate. The group permissions then decide what members of that team are allowed to do with the file.</p><h3>2. Permission Types: Files vs. Directories</h3><p>There are three basic types of permissions in Linux: <strong>Read (</strong><strong>r)</strong>, <strong>Write (</strong><strong>w)</strong>, and <strong>Execute (</strong><strong>x)</strong>. However, these permissions function differently depending on whether they are applied to a regular file or a directory.</p><p>PermissionSymbol &amp; Octal ValueFunction on a FileFunction on a Directory<strong>Read</strong>r (4)Allows reading or viewing file contents (e.g., using cat or less).Allows listing the files and subdirectories inside (e.g., using ls).<strong>Write</strong>w (2)Allows editing, modifying, or overwriting the file.Allows creating, deleting, or renaming files inside the directory.<strong>Execute</strong>x (1)Allows running the file as a script or program (e.g., ./script.sh).Allows entering or traversing the directory (e.g., using cd).</p><blockquote><strong><em>Important Note:</em></strong><em> To access or interact with files inside a directory, a user must have </em><strong><em>Execute (</em></strong><strong><em>x)</em></strong><em> permission on that directory.</em></blockquote><h3>3. Permission Targets and ls -l Structure</h3><p>Permissions are assigned to three distinct entity levels:</p><ol><li><strong>Owner (</strong><strong>u):</strong> The single user who created or owns the file.</li><li><strong>Group (</strong><strong>g):</strong> Members of the group associated with the file.</li><li><strong>Others (</strong><strong>o):</strong> All other system users not covered by Owner or Group.</li></ol><p>When you run ls -l in the terminal, Linux displays permission strings alongside ownership details:</p><pre>-rwxr-xr-- 1 nora developers 4096 Sep 22 14:30 script.sh<br>drwxr-xr-x 2 nora developers 4096 Sep 22 14:30 projects</pre><h3>Breakdown of -rwxr-xr--:</h3><ul><li><strong>1st Character (</strong><strong>-):</strong> Represents the file type (- for regular file, d for directory).</li><li><strong>Next 3 Characters (</strong><strong>rwx):</strong> Owner permissions. <strong>Nora</strong> can read, write, and execute.</li><li><strong>Middle 3 Characters (</strong><strong>r-x):</strong> Group permissions. Members of developers can read and execute, but cannot edit.</li><li><strong>Last 3 Characters (</strong><strong>r--):</strong> Others permissions. All remaining users can only read the file.</li></ul><h3>4. Modifying File Permissions with chmod</h3><p>When you need to adjust access rights, you use the <strong>chmod</strong> (<em>change mode</em>) command. This can be done in two ways: <strong>Symbolic Mode</strong> or <strong>Numeric (Octal) Mode</strong>.</p><h3>A. Symbolic Mode</h3><p>Uses letters and mathematical operators to add or remove specific permissions.</p><p><strong>Syntax:</strong></p><pre>chmod [target] [operator] [permission] [filename]</pre><ul><li><strong>Targets:</strong> u (user), g (group), o (others), a (all)</li><li><strong>Operators:</strong> + (add), - (remove), = (set exact)</li><li><strong>Permissions:</strong> r (read), w (write), x (execute)</li></ul><p><strong>Examples:</strong></p><pre># Grant execute permission to Nora (owner)<br>chmod u+x script.sh</pre><pre># Remove write permission from group and others<br>chmod go-w document.txt</pre><h3>B. Numeric (Octal) Mode</h3><p>Uses a 3-digit number representing total permission values for User, Group, and Others.</p><ul><li>4 = Read</li><li>2 = Write</li><li>1 = Execute</li><li>0 = None</li></ul><p><strong>Common Examples:</strong></p><p>Bash</p><pre># Owner: rwx (7), Group: r-x (5), Others: r-x (5)<br>chmod 755 script.sh</pre><pre># Owner: rw- (6), Group: r-- (4), Others: r-- (4)<br>chmod 644 config.conf</pre><h3>5. Managing Ownership with chown and chgrp</h3><p>File ownership and group association are independent properties. Changing a file’s group does not require changing its owner, and the owner does not strictly have to belong to that group (though normal users can only reassign files to groups they are members of).</p><p>To manage ownership, Linux provides <strong>chown</strong> (<em>change owner</em>) and <strong>chgrp</strong> (<em>change group</em>).</p><h3>A. Changing Both Owner and Group</h3><pre># Syntax<br>chown [new_owner]:[new_group] [filename]</pre><pre># Change owner to &quot;nora&quot; and group to &quot;developers&quot;<br>chown nora:developers project.py</pre><h3>B. Changing Only the Group</h3><p>You can modify the file’s group without altering the owner using either chown with a colon prefix or chgrp.</p><pre># Method 1: Using chown with a colon (leaves the owner unchanged)<br>chown :sysadmins script.sh</pre><pre># Method 2: Using chgrp (specifically designed for group updates)<br>chgrp sysadmins script.sh</pre><h3>C. Recursive Ownership Changes</h3><p>To update an entire directory tree along with all enclosed files and subfolders, use the <strong>-R</strong> flag:</p><pre>chown -R nora:developers /var/www/myteam/</pre><h3>6. Special Permissions: SUID, SGID, and Sticky Bit</h3><p>In addition to standard access rights, Linux provides special permission bits: <strong>SUID</strong> (Set User ID), <strong>SGID</strong> (Set Group ID), and the <strong>Sticky Bit</strong>.</p><h3>A. SUID and SGID Mechanisms</h3><p>It is important to emphasize that SUID and SGID are not permissions granted to individual users. Instead, these bits are attached directly to the file itself, and the file’s permission settings remain static. Through SUID and SGID bits, Linux allows users to access files or directories that they normally cannot read, write, or execute under their own accounts. In other words, these special files serve as a mechanism that enables ordinary users to perform privileged system actions that they would otherwise lack the permissions to execute.</p><p>When an executable file with SUID or SGID is run, the system process does not run with the identity of the user who launched it. Instead, the process runs with the full access rights of the file’s owner or group. For instance, if an application owned by root has the SUID bit set, running that application allows a normal user to read from or write to restricted system configuration files for the duration of that program&#39;s execution.</p><ul><li><strong>SUID (Set User ID):</strong> Attached to executable files. The resulting process runs with the privileges of the file’s <strong>User Owner</strong> (frequently root).</li><li><em>Numeric value:</em> Adds 4000 to the permission mode (e.g., chmod 4755 custom_tool).</li><li><strong>SGID (Set Group ID):</strong> Attached to files or directories.</li><li>On a <strong>file</strong>, the process runs with the privileges of the file’s <strong>Group Owner</strong>.</li><li>On a <strong>directory</strong>, newly created files automatically inherit the directory’s group ownership.</li><li><em>Numeric value:</em> Adds 2000 to the permission mode (e.g., chmod 2755 shared_folder).</li></ul><h3>B. The Sticky Bit: Protecting Shared Workspaces</h3><p>Sticky bits in Linux function like personal locks on files within shared spaces. When set on a directory, the sticky bit adds an extra layer of security, ensuring that only specific individuals can modify or delete files, even if multiple users have write access to the directory itself.</p><p>Imagine a communal workspace where many people can enter and use shared tools, but each person has their own drawer that only they (or the manager) can open. The sticky bit acts like a lock on these drawers, preventing anyone else from tampering with or removing the contents. In a shared directory (such as /tmp), this means that only the <strong>file&#39;s owner</strong>, the <strong>directory&#39;s owner</strong>, or the <strong>root user</strong> can delete or rename files. Other users can still create and modify their own files inside the directory, but they cannot tamper with files owned by others.</p><p>This feature is essential in public or collaborative environments. By setting the sticky bit, you ensure that important shared files are not accidentally or maliciously deleted by someone lacking authority, adding a critical safeguard to multi-user environments.</p><ul><li><strong>Sticky Bit:</strong> Attached primarily to shared directories.</li><li><em>Numeric value:</em> Adds 1000 to the permission mode (e.g., chmod 1777 /tmp or chmod +t /shared_dir).</li></ul><h3>C. Case Sensitivity in Special Permission Symbols</h3><p>When inspecting special permissions using ls -l, notice the casing of the characters in the permission string. The presence of the underlying <strong>Execute (</strong><strong>x)</strong> permission determines whether the symbol appears in lowercase or uppercase:</p><p><strong>Special BitExecution (x) PresentExecution (x) MissingDescriptionSUID</strong>s (-rwsr-xr-x)S (-rwSr-xr-x)Small s means executable with SUID. Big S indicates SUID is set without execute permissions (ineffective configuration).<strong>SGID</strong>s (-rwxr-sr-x)S (-rwxr-Sr-x)Small s means executable with SGID. Big S indicates SGID is set without execute permissions.<strong>Sticky Bit</strong>t (drwxrwxrwt)T (drwxrwxr-T)Small t means Sticky Bit is set WITH execute permissions for others. Big T means Sticky Bit is set WITHOUT execute permissions for others.</p><h4>Real-World Example:</h4><pre>cry0l1t3@htb[/htb]$ ls -l</pre><pre>drw-rw-r-t 3 cry0l1t3 cry0l1t3   4096 Jan 12 12:30 scripts<br>drw-rw-r-T 3 cry0l1t3 cry0l1t3   4096 Jan 12 12:32 reports</pre><p>In this output, both directories have the sticky bit applied:</p><ul><li>The <strong>scripts</strong> folder displays a <strong>lowercase </strong><strong>t</strong>, meaning the sticky bit is active <strong>and</strong> execute (x) permissions are set for others, allowing users to enter and access contents according to ownership.</li><li>The <strong>reports</strong> folder displays an <strong>uppercase </strong><strong>T</strong>, meaning the sticky bit is set <strong>but</strong> execute (x) permissions for others are missing. As a result, other users cannot enter or list the folder&#39;s contents despite the sticky bit configuration.</li></ul><h3>Examples of Setting Special Permissions:</h3><pre># Set SUID on an executable tool<br>chmod u+s /usr/bin/custom_tool<br>chmod 4755 /usr/bin/custom_tool</pre><pre># Set SGID on a collaborative directory<br>chmod g+s /var/shared_project/<br>chmod 2755 /var/shared_project/</pre><pre># Set Sticky Bit on a public shared directory<br>chmod +t /var/public_share/<br>chmod 1777 /var/public_share/</pre><h3>Final Thoughts</h3><p>Understanding Linux permissions isn’t just about memorizing chmod 755 or chmod 644. It&#39;s about understanding how Linux manages boundaries, processes, and access controls. Once you grasp how SUID/SGID shifts process execution identities and how special bits interact with underlying execute flags, navigating system administration and security testing becomes much more intuitive.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93842216e94e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>