# Chmod file permission calculator (`mangudai/chmod-file-permission-calculator`) Actor

Decode Unix file permissions between octal and symbolic form, apply chmod expressions like u+x,go-w to a base mode, and turn a umask into the defaults new files and directories get. One row per calculation with both notations, per class flags, special bits, a ready chmod command and a note.

- **URL**: https://apify.com/mangudai/chmod-file-permission-calculator.md
- **Developed by:** [Mangudäi](https://apify.com/mangudai) (community)
- **Categories:** Developer tools, Automation, Open source
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Chmod file permission calculator

Work out Unix file permissions without leaving your browser or guessing at bits. Give it a mode and it returns the octal form, the symbolic form, what each class can do, the special bits, a ready `chmod` command, and a short security note. It also applies `chmod` expressions to a starting mode and turns a umask into the defaults new files and directories receive.

Everything runs offline as plain arithmetic. No API key, no login, no external service. The same input always gives the same answer, so it never breaks.

### What it does

Three calculation types, mixed freely in a single run:

**decode** reads a mode and explains it. Pass octal like `755`, `0755` or `4755`, or symbolic like `rwxr-xr-x` or `-rw-r--r--`. You get both notations back plus the per class breakdown, so it doubles as an octal to symbolic converter and back.

**chmod** applies a symbolic expression to a base mode the way the command line does. Base `644` with expression `u+x,go-w` returns `744`. It understands `u`, `g`, `o`, `a`, the `+`, `-` and `=` operators, `r`, `w`, `x`, the conditional `X`, and the `s` and `t` special bits.

**umask** converts a umask into the permissions new files and new directories start with. A umask of `022` gives files `644` and directories `755`.

### Input

Send a `calculations` array. Each item is one calculation.

```json
{
  "calculations": [
    { "type": "decode", "mode": "755" },
    { "type": "decode", "mode": "-rw-r--r--" },
    { "type": "decode", "mode": "4755" },
    { "type": "chmod", "base": "644", "expression": "u+x,go-w" },
    { "type": "umask", "umask": "022" }
  ]
}
```

You can leave out `type`. If an item has an `expression` it is treated as a chmod, a `umask` field makes it a umask, and anything else is a decode. Run it with no input and it uses a set of worked examples so you can see the shape of the output straight away.

### Output

One row per calculation, written to the dataset with a table view. Key columns:

- `octal` and `symbolic`: the mode in both notations, for example `755` and `rwxr-xr-x`
- `owner`, `group`, `other`: the three permission triads
- `setuid`, `setgid`, `sticky`: the special bits as true or false
- `description`: a plain reading, for example "Owner: read, write, execute. Group: read, execute. Others: read, execute."
- `command`: a copy and paste `chmod` command
- `notes`: a security flag when something stands out, such as a world-writable or setuid mode
- `ok` and `error`: a bad input returns an error row and the run keeps going

Each row also carries the finer detail: the four digit octal with the special digit, the ten character symbolic string with the file type, every read, write and execute flag on its own, and for umask rows the separate file and directory defaults.

### How the permission math works

A Unix mode is four octal digits. The first is the special set (setuid 4, setgid 2, sticky 1) and the next three are owner, group and other, each built from read 4, write 2 and execute 1. Symbolic notation writes the same thing as `rwx` triads, with `s` or `S` marking setuid and setgid and `t` or `T` marking the sticky bit. This actor converts between the two, applies chmod clauses, and masks the base defaults with a umask. The conditional `X` sets execute only when execute is already present somewhere in the base mode, matching how the command behaves on files.

### Good to know

The output describes permissions, it does not change any file. Use the `command` column to apply a mode on your own system. The security notes point out common risks like world-writable files and setuid binaries, but they are a quick check, not a full audit.

# Actor input Schema

## `calculations` (type: `array`):

A list of permission calculations. Each item is an object. Set "type" to "decode", "chmod" or "umask".

decode: read a mode written as octal (for example 755, 0755, 4755) or symbolic (for example rwxr-xr-x or -rw-r--r--). Use the "mode" field.

chmod: apply a symbolic expression to a base mode, the way the chmod command does. Use "base" (for example 644) and "expression" (for example u+x,go-w or a=r).

umask: turn a umask into the default permissions new files and directories get. Use the "umask" field (for example 022).

Type can be left out and it is inferred from the fields you provide.

## Actor input object example

```json
{
  "calculations": [
    {
      "type": "decode",
      "mode": "755"
    },
    {
      "type": "decode",
      "mode": "644"
    },
    {
      "type": "decode",
      "mode": "600"
    },
    {
      "type": "decode",
      "mode": "rwxr-xr-x"
    },
    {
      "type": "decode",
      "mode": "4755"
    },
    {
      "type": "decode",
      "mode": "1777"
    },
    {
      "type": "decode",
      "mode": "-rw-r--r--"
    },
    {
      "type": "chmod",
      "base": "644",
      "expression": "u+x,go-w"
    },
    {
      "type": "chmod",
      "base": "600",
      "expression": "a+r"
    },
    {
      "type": "umask",
      "umask": "022"
    },
    {
      "type": "umask",
      "umask": "077"
    }
  ]
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "calculations": [
        {
            "type": "decode",
            "mode": "755"
        },
        {
            "type": "decode",
            "mode": "644"
        },
        {
            "type": "decode",
            "mode": "600"
        },
        {
            "type": "decode",
            "mode": "rwxr-xr-x"
        },
        {
            "type": "decode",
            "mode": "4755"
        },
        {
            "type": "decode",
            "mode": "1777"
        },
        {
            "type": "decode",
            "mode": "-rw-r--r--"
        },
        {
            "type": "chmod",
            "base": "644",
            "expression": "u+x,go-w"
        },
        {
            "type": "chmod",
            "base": "600",
            "expression": "a+r"
        },
        {
            "type": "umask",
            "umask": "022"
        },
        {
            "type": "umask",
            "umask": "077"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mangudai/chmod-file-permission-calculator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "calculations": [
        {
            "type": "decode",
            "mode": "755",
        },
        {
            "type": "decode",
            "mode": "644",
        },
        {
            "type": "decode",
            "mode": "600",
        },
        {
            "type": "decode",
            "mode": "rwxr-xr-x",
        },
        {
            "type": "decode",
            "mode": "4755",
        },
        {
            "type": "decode",
            "mode": "1777",
        },
        {
            "type": "decode",
            "mode": "-rw-r--r--",
        },
        {
            "type": "chmod",
            "base": "644",
            "expression": "u+x,go-w",
        },
        {
            "type": "chmod",
            "base": "600",
            "expression": "a+r",
        },
        {
            "type": "umask",
            "umask": "022",
        },
        {
            "type": "umask",
            "umask": "077",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("mangudai/chmod-file-permission-calculator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "calculations": [
    {
      "type": "decode",
      "mode": "755"
    },
    {
      "type": "decode",
      "mode": "644"
    },
    {
      "type": "decode",
      "mode": "600"
    },
    {
      "type": "decode",
      "mode": "rwxr-xr-x"
    },
    {
      "type": "decode",
      "mode": "4755"
    },
    {
      "type": "decode",
      "mode": "1777"
    },
    {
      "type": "decode",
      "mode": "-rw-r--r--"
    },
    {
      "type": "chmod",
      "base": "644",
      "expression": "u+x,go-w"
    },
    {
      "type": "chmod",
      "base": "600",
      "expression": "a+r"
    },
    {
      "type": "umask",
      "umask": "022"
    },
    {
      "type": "umask",
      "umask": "077"
    }
  ]
}' |
apify call mangudai/chmod-file-permission-calculator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=mangudai/chmod-file-permission-calculator",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/xKnpydWujKd5VXutN/builds/QmanQaGWaCNtfLtFg/openapi.json
