<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adavize</title>
    <description>The latest articles on DEV Community by Adavize (@ize).</description>
    <link>https://dev.to/ize</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F197794%2F2e1ead0c-eec2-436f-9ce8-cb6d0e55a44c.jpg</url>
      <title>DEV Community: Adavize</title>
      <link>https://dev.to/ize</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ize"/>
    <language>en</language>
    <item>
      <title>Building a Real-Time System Monitor with Zig, Bun, and WebSockets</title>
      <dc:creator>Adavize</dc:creator>
      <pubDate>Thu, 19 Mar 2026 08:41:33 +0000</pubDate>
      <link>https://dev.to/ize/building-a-real-time-system-monitor-with-zig-bun-and-websockets-1kbh</link>
      <guid>https://dev.to/ize/building-a-real-time-system-monitor-with-zig-bun-and-websockets-1kbh</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Most monitoring tools are either bloated or cloud-dependent. I wanted something minimal, local, and fast so I built one using Zig for system-level collection and Bun for a real-time WebSocket API. Here is how I approached it.&lt;/p&gt;

&lt;h2&gt;
  
  
  System architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F69fzkchnfngbwq3fxxow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F69fzkchnfngbwq3fxxow.png" alt="system architecture for local monitoring tool" width="701" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The core idea is simple: collect system metrics at regular intervals, store them in a database for later access, and broadcast updates to a web interface in real time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Metric collectors
&lt;/h3&gt;

&lt;p&gt;The first step is a set of metric collectors that reads system metrics ands send them to the API every second.&lt;/p&gt;

&lt;p&gt;I chose the &lt;a href="https://ziglang.org/" rel="noopener noreferrer"&gt;Zig&lt;/a&gt; programming language for this. Why Zig?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Zig is a modern alternative to C, offering better safety and performance while giving explicit control over memory. This makes it ideal for building lightweight tools with minimal overhead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Zig provides native access to system resources which enables direct interaction with hardware while offering stronger memory checks than C.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To keep this article concise, I'll explain each metric collector in plain English rather than diving deeply into implementation details.&lt;/p&gt;

&lt;h4&gt;
  
  
  CPU metric
&lt;/h4&gt;

&lt;p&gt;CPU usage is captured from &lt;code&gt;/proc/stat&lt;/code&gt;. The &lt;code&gt;/proc&lt;/code&gt; directory in Linux is a virtual filesystem managed by the kernel that exposes real-time system and process information. Other system metrics are also available here.&lt;/p&gt;

&lt;p&gt;Flow for CPU metric collector:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt; Get first reading from /proc/stat &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; After first reading cycle &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Get second reading from /proc/stat &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Calculate delta total and delta active difference &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Compute the CPU usage &lt;span class="k"&gt;in &lt;/span&gt;percentage &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Send to API Service &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;CPU usage is calculated by comparing two readings of CPU time and computing the percentage of time spent doing active work versus idle time.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://github.com/ize-302/mini-monitoring-tool/blob/main/collectors/cpu.zig" rel="noopener noreferrer"&gt;Source code for CPU metric collector here&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  Memory metric
&lt;/h4&gt;

&lt;p&gt;Memory metrics are read from &lt;code&gt;/proc/meminfo&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Flow for memory metric collection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt; Read total memory from /proc/meminfo &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Read available memory from /proc/meminfo &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Compute the percentage being used &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Send to API Service &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/ize-302/mini-monitoring-tool/blob/main/collectors/memory.zig" rel="noopener noreferrer"&gt;Source code for memory metric collector here&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  Temperature metric
&lt;/h4&gt;

&lt;p&gt;Temperature metrics are read from the &lt;code&gt;/sys&lt;/code&gt; virtual filesystem, which exposes hardware attributes and allows inspection or control of devices. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;While &lt;code&gt;/proc&lt;/code&gt; provides system and process stats, &lt;code&gt;/sys&lt;/code&gt; exposes hardware-level information such as temperature sensors and power supply data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Flow diagram of temperature metric collector:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt; Read the content of /sys/class/thermal/thermal_zone0/temp &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Convert from millidegrees Celsius to degree Celsius &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Send to API Service &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/ize-302/mini-monitoring-tool/blob/main/collectors/temperature.zig" rel="noopener noreferrer"&gt;Source code for temperature metric collector here&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  Battery metric
&lt;/h4&gt;

&lt;p&gt;Battery metrics are also read from &lt;code&gt;/sys&lt;/code&gt;. The collector reads the battery capacity from &lt;code&gt;/sys/class/power_supply/BAT0/capacity&lt;/code&gt; (as a percentage) and sends it to the API.&lt;/p&gt;

&lt;p&gt;Flow diagram of battery metric collector:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt; Read the content of /sys/class/power_supply/BAT0/capacity &lt;span class="o"&gt;]&lt;/span&gt;
      |
&lt;span class="o"&gt;[&lt;/span&gt; Send to API Service &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/ize-302/mini-monitoring-tool/blob/main/collectors/battery.zig" rel="noopener noreferrer"&gt;Source code for battery metric collector here&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  API service
&lt;/h3&gt;

&lt;p&gt;Once metrics are collected, the next step is to store and make them available to clients in real time. This is handled by a lightweight API service. &lt;/p&gt;

&lt;p&gt;The API service is built with &lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;TypeScript&lt;/a&gt; and &lt;a href="https://bun.com/docs" rel="noopener noreferrer"&gt;Bun&lt;/a&gt;. Bun is a fast Javascript runtime designed for modern applications, with built-in HTTP, WebSocket, and SQLite support.&lt;/p&gt;

&lt;p&gt;Why Bun?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast and easy to setup&lt;/li&gt;
&lt;li&gt;Built-in WebSockets support&lt;/li&gt;
&lt;li&gt;Built-in SQLite&lt;/li&gt;
&lt;li&gt;No need for extra tooling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Web API service is responsible for:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Persisting collected metrics in SQLite&lt;/li&gt;
&lt;li&gt;Broadcasting metrics to connected clients via WebSockets&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;
  
  
  Endpoints:
&lt;/h5&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Route&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/metrics/cpu&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ingest CPU usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/metrics/memory&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ingest memory usage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/metrics/temperature&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ingest temperature&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/metrics/battery&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ingest battery level&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/api/history?metric=&amp;lt;name&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Last 200 data points for a metric&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;WS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/ws&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Real-time broadcast of all incoming metrics&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  Database
&lt;/h3&gt;

&lt;p&gt;SQLite is used for its lightweight nature and simplicity, making it ideal for a local monitoring tool.&lt;/p&gt;

&lt;h4&gt;
  
  
  Metric table
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Column&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Constraints&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;id&lt;/td&gt;
&lt;td&gt;INTEGER&lt;/td&gt;
&lt;td&gt;PRIMARY KEY, AUTOINCREMENT&lt;/td&gt;
&lt;td&gt;Unique row identifier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;metric&lt;/td&gt;
&lt;td&gt;TEXT&lt;/td&gt;
&lt;td&gt;NOT NULL&lt;/td&gt;
&lt;td&gt;Metric type (cpu, memory, temperature, etc.)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;value&lt;/td&gt;
&lt;td&gt;REAL&lt;/td&gt;
&lt;td&gt;NOT NULL&lt;/td&gt;
&lt;td&gt;Recorded metric value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ts&lt;/td&gt;
&lt;td&gt;INTEGER&lt;/td&gt;
&lt;td&gt;NOT NULL&lt;/td&gt;
&lt;td&gt;Unix timestamp of when the metric was recorded&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Writing to the database every second could cause performance issues, so SQLite is configured for Write-Ahead Logging (WAL) and relaxed synchronous mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;PRAGMA journal_mode = WAL;&lt;/code&gt;&lt;br&gt;
This configures SQLite to write to a separate WAL file before merging into the main database thereby improving concurrency and write performance, at the cost of slightly more disk usage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;PRAGMA synchronous = NORMAL;&lt;/code&gt;&lt;br&gt;
This configuration reduces the number of disk sync operations for faster writes. In rare cases (e.g., sudden power loss), some recent writes may be lost—acceptable for this use case.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Web dashboard
&lt;/h3&gt;

&lt;p&gt;Finally, to visualize the metrics in real time, I built a simple web interface that connects to the WebSocket endpoint. Whenever the API receives a new metric, it broadcasts it to all connected clients. The frontend listens for these events and updates the UI accordingly.&lt;/p&gt;

&lt;p&gt;This approach avoids polling and ensures that the dashboard reflects system changes instantly.&lt;/p&gt;

&lt;p&gt;I used &lt;a href="https://canvasjs.com/" rel="noopener noreferrer"&gt;CanvasJS&lt;/a&gt; for visualization, providing charts that show trends over time at a glance.&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Building this monitoring tool helped me gain hands-on experience with Linux virtual filesystems (&lt;code&gt;/proc&lt;/code&gt; and &lt;code&gt;/sys&lt;/code&gt;) and real-time WebSocket communication.&lt;/p&gt;

&lt;p&gt;While this is minimal, there are several possible improvements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding alerting for threshold breaches
&lt;/li&gt;
&lt;li&gt;Enhancing the visualization layer
&lt;/li&gt;
&lt;li&gt;Aggregating metrics over time for example:

&lt;ul&gt;
&lt;li&gt;average CPU usage over 1 minute&lt;/li&gt;
&lt;li&gt;maximum temperature over 5 minutes&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Overall, this project was an excellent hands-on learning experience, deepening my understanding of low-level system operations and real-time data streaming.&lt;/p&gt;

&lt;p&gt;Thank you for taking the time to read. Looking forward to whatever questions or suggestions you may have.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here is the &lt;a href="https://github.com/ize-302/mini-monitoring-tool" rel="noopener noreferrer"&gt;link&lt;/a&gt; to the entire source code. Happy digging! &lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>linux</category>
      <category>zig</category>
      <category>webdev</category>
      <category>sqlite</category>
    </item>
    <item>
      <title>Understanding file access permissions in Unix-like systems</title>
      <dc:creator>Adavize</dc:creator>
      <pubDate>Wed, 13 Dec 2023 11:30:15 +0000</pubDate>
      <link>https://dev.to/ize/understanding-file-access-permissions-in-unix-like-systems-2ckp</link>
      <guid>https://dev.to/ize/understanding-file-access-permissions-in-unix-like-systems-2ckp</guid>
      <description>&lt;p&gt;Before we jump right in, allow me to test your knowledge on this topic. Take a look at this list below, Can you confidently interpret the file access permissions on each line?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;drwxr-xr-x   7 user1  group3   224 Jun 10  2022 nodejs-tutorials
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt;   3 user1  group1    96 Nov 25 00:25 hello_world.txt
drwxr--r--  20 user3  group2   640 Oct 23 18:56 docker-notes
lrwxr-xr--   3 user1  group2    96 Sep 12 10:58 repos
&lt;span class="nt"&gt;-rwxr-xr-x&lt;/span&gt;  11 user2  group1   352 Oct  5 11:42 main.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your answer is "NO," then this article is for you. Here, Together, we will explore the concept of file access permissions, including its composition, various access levels, how to grant user and group access to a file, and more. By the end, you should have a comprehensive understanding of this topic.&lt;/p&gt;

&lt;p&gt;BTW, the strange looking characters at the beginning of each line are called 'permission bits'. They are a set of flags in a Unix-like operating system that define the access rights of a file or directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what is file access permission?
&lt;/h2&gt;

&lt;p&gt;File access permissions refer to the rules and settings that determines who can perform specific actions (such as reading, writing, or executing) on a file or directory within a computer's file system.&lt;/p&gt;

&lt;p&gt;It shouldn't be surprising that at the core of file access permissions are files, permissions and access levels. So let let us take a look at each aspect:&lt;/p&gt;

&lt;h2&gt;
  
  
  Files
&lt;/h2&gt;

&lt;p&gt;Files are categorised into several types based on their characteristics and usage. They include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Regular file: These are the most common type of files that contain data, such as texts, images, or programs. In Unix based file systems, files are represented by the '-' character&lt;/li&gt;
&lt;li&gt;Directory: These files contain lists of other files and directories. They are represented by the 'd' character&lt;/li&gt;
&lt;li&gt;Symbolic link or symlink: These are links or references to existing files or directories. They allow you to create a link to a target file or directory from another location in the file system. Symbolic links are represented by the 'l' character&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Permissions
&lt;/h2&gt;

&lt;p&gt;Every file or directory that exists in a system has permission and access level depending on the desired need. Permissions for a file can be one of or a combination of read, write and execute:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read permission allows reading a file's contents and listing a directory's contents, respectively. It is represented by the letter 'r'&lt;/li&gt;
&lt;li&gt;Write permission allows for the modification of a file’s contents and creating, deleting, and renaming files within a directory. Write permission is represented by the letter 'w'&lt;/li&gt;
&lt;li&gt;Execute permission allows executing the file if it is a program or script and accessing a directory. It is represented by the letter 'x'&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Access levels
&lt;/h2&gt;

&lt;p&gt;Each permission 'read' 'write' 'execute' can be controlled within three(3) access levels of user, group and others;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User represents the owner of the file or directory&lt;/li&gt;
&lt;li&gt;Group represents a collection of users associated with the file or directory&lt;/li&gt;
&lt;li&gt;Others represents every other user in the system who are not the owner and also do not belong to the group associated with that file or directory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This diagram below breaks down permission bits, illustrating how file type is presented and how permissions are represented for each access level&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5byjegq48by91fw6q4qo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5byjegq48by91fw6q4qo.png" alt="diagram showing the breakdown of permission bits" width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first letter in this case the letter 'd' represents the file type which is a directory&lt;/li&gt;
&lt;li&gt;The next 3 characters represent permissions for the user or owner of the file&lt;/li&gt;
&lt;li&gt;The following 3 characters in green represent the members of the associated group&lt;/li&gt;
&lt;li&gt;The last 3 characters represent permissions for others who do not own the directory or are not members of the associated group&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that you understand the composition of permission bits, let us apply this new found knowledge to the example we saw earlier. I added some comments explaining each section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# d: 'nodejs-tutorials' is a directory&lt;/span&gt;
&lt;span class="c"&gt;# rwx: user/file owner(user1) has read, write and execute permission&lt;/span&gt;
&lt;span class="c"&gt;# r-x: associated group(group3) has read and execute permission&lt;/span&gt;
&lt;span class="c"&gt;# r-x: others have read and execute permission&lt;/span&gt;
drwxr-xr-x   7 user1  group3    224 Jun 10  2022 nodejs-tutorials

&lt;span class="c"&gt;# -: 'hello_world.txt' is a regular file&lt;/span&gt;
&lt;span class="c"&gt;# rw-: user/file owner(user1) has read, and write permission&lt;/span&gt;
&lt;span class="c"&gt;# rw-: associated group(group1) has read and write permission&lt;/span&gt;
&lt;span class="c"&gt;# r--: others have only read permission&lt;/span&gt;
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt;   3 user1  group1    96 Nov 25 00:25 hello_world.txt


&lt;span class="c"&gt;# d: 'docker-notes' is a directory&lt;/span&gt;
&lt;span class="c"&gt;# rwx: user/file owner(user3) has read, write, execute permission&lt;/span&gt;
&lt;span class="c"&gt;# r--: associated group(group2) has only read permission&lt;/span&gt;
&lt;span class="c"&gt;# r--: others have only read permission&lt;/span&gt;
drwxr--r--  20 user3  group2   640 Oct 23 18:56 docker-notes

&lt;span class="c"&gt;# l: 'repos' is a symbolic link or symlink&lt;/span&gt;
&lt;span class="c"&gt;# rwx: user/file owner(user1) has read, write and execute permission&lt;/span&gt;
&lt;span class="c"&gt;# r-x: associated group(group2) has read and execute permission&lt;/span&gt;
&lt;span class="c"&gt;# r--: others have only read permission&lt;/span&gt;
lrwxr-xr--   3 user1  group2    96 Sep 12 10:58 repos

&lt;span class="c"&gt;# -: 'main.sh' is a regular file&lt;/span&gt;
&lt;span class="c"&gt;# rwx: user/file owner(user2) has read, write and execute permission&lt;/span&gt;
&lt;span class="c"&gt;# r-x: group(group1) has read and execute permission&lt;/span&gt;
&lt;span class="c"&gt;# r-x: others have read and execute permission&lt;/span&gt;
&lt;span class="nt"&gt;-rwxr-xr-x&lt;/span&gt;  11 user2  group1   352 Oct  5 11:42 main.sh

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to update file permissions
&lt;/h2&gt;

&lt;p&gt;Changes to file permissions in a Unix-like system can be achieved using the &lt;code&gt;chmod&lt;/code&gt; command. The &lt;code&gt;chmod&lt;/code&gt; command expects 2 arguments: the [MODE] and the [FILE]&lt;/p&gt;

&lt;p&gt;i.e &lt;code&gt;$ chmod MODE FILE&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The MODE can be specified using either symbolic or numeric representation but I will only be focusing on symbolic representation as it is easier to grasp and remember:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;u+x main.sh &lt;span class="c"&gt;# gives execution permission to the user or file owner&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;o-rw main.sh &lt;span class="c"&gt;# removes read and write permission from other users&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;g+w main.sh &lt;span class="c"&gt;# gives write permission from the group&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What if we want to grant all 3 permissions to all access levels?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# This gives read, write, execute permission to the user, group and other users&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;ugo+rwx main.sh
&lt;span class="c"&gt;# The above can otherwise be written as:&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;a+rwx main.sh
&lt;span class="c"&gt;# 'a' which means all can be used to represent all access levels&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that is it, hopefully this article turned out helpful and you are able to get a better understanding of file access permissions. If you found this helpful, let me know by liking, sharing and leaving comments.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

</description>
      <category>unix</category>
      <category>permission</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
