Decoding POSIX Mode Bits: Octal Triads, Directories, and Special Flags
Every file and directory on a Linux or macOS POSIX filesystem stores a 12-bit permission mask divided into four 3-bit groups: Special flags (setuid=4, setgid=2, sticky=1), Owner/User (r=4, w=2, x=1), Group (r=4, w=2, x=1), and Others/World (r=4, w=2, x=1).
Understanding the difference between files and directories is critical: on a regular file, execute (x=1) grants permission to run the file as a program; on a directory, execute (x=1) is the 'traverse/search' bit required to cd into the directory or stat inodes inside it. That is why standard non-executable web assets use 0644 (-rw-r--r--) while their parent directories require 0755 (drwxr-xr-x).
Special bits solve multi-user operational challenges: the sticky bit (1000, shown as trailing t in drwxrwxrwt on /tmp) allows any user to create files in a shared directory while restricting deletion solely to the file's owner or root.
chmod 600 ~/.ssh/id_ed25519 # Private SSH key (owner rw only; required by ssh) chmod 700 ~/.ssh # Private SSH directory (owner rwx only) chmod 644 /etc/nginx/nginx.conf # Config file (owner rw, world readable) chmod 755 /usr/local/bin/deploy # Executable script (owner rwx, world rx)
5-Field Cron Expressions: Avoiding the Wildcard-Minute Outage
Standard Vixie cron syntax consists of five whitespace-separated fields: Minute (0–59), Hour (0–23), Day of Month (1–31), Month (1–12), and Day of Week (0–6, where 0 is Sunday). Cloud schedulers—including GitHub Actions schedule triggers, Kubernetes CronJobs, AWS EventBridge, and Vercel Cron—evaluate cron expressions in UTC by default.
The most expensive cron mistake in production is writing * 2 * * * when intending to run a nightly database backup at 02:00 UTC. Because the Minute field is *, the job launches every single minute from 02:00 through 02:59 (60 concurrent backups!). Always pin the Minute field explicitly (0 2 * * *).
Also remember a subtle POSIX quirk: when both Day-of-Month and Day-of-Week are restricted (neither is *), standard cron treats them as a logical OR rather than AND!
Unix Epoch Seconds vs. Milliseconds and Timezone Hygiene
Unix time counts non-leap seconds elapsed since 1970-01-01T00:00:00Z. Backend languages and specs vary on unit granularity: POSIX C time(), Python int(time.time()), Go time.Now().Unix(), PostgreSQL EXTRACT(EPOCH ...), and JWT exp/iat use 10-digit seconds (~1.76 × 10^9), whereas JavaScript Date.now() and Java System.currentTimeMillis() use 13-digit milliseconds (~1.76 × 10^12).
Passing a 10-digit seconds integer directly into JavaScript's new Date(1764410000) yields January 21, 1970! Always normalize units at API boundaries and store/transmit human-readable dates strictly in UTC ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ).
Translating DevTools cURL Captures into Clean Client Requests
During incident triage, reproducing an authenticated browser request via Chrome DevTools 'Copy as cURL' and converting it locally into typed fetch() or Axios scripts lets engineers write regression tests rapidly without leaking session cookies to external converters.
Standard Linux Chmod Octal Modes Quick Reference
| Octal Mode | Symbolic String | Target Type | Typical Production Usage |
|---|---|---|---|
| 0600 | -rw------- | Sensitive file | SSH private keys, .env secrets, TLS private keys |
| 0644 | -rw-r--r-- | Regular file | HTML/CSS/JS static assets, public certs, systemd units |
| 0700 | drwx------ | Private directory | ~/.ssh, PostgreSQL PGDATA directory |
| 0755 | drwxr-xr-x | Executable / Dir | CLI binaries, scripts, web server document directories |
| 1777 | drwxrwxrwt | Shared temp dir | /tmp and /var/tmp (world-writable + sticky delete guard) |
Production Engineering Checklist
- Never run chmod 777 to troubleshoot permission errors; inspect process UID/GID ownership and use 755/644/600.
- Double-check that daily/hourly cron schedules specify an integer minute (e.g., 0 or 15), never *.
- Verify whether timestamps represent 10-digit seconds or 13-digit milliseconds before converting.
- Configure servers and CI/CD cron runners in UTC to eliminate Daylight Saving Time (DST) skipped/duplicated runs.
Frequently Asked Questions
Why did my cron job run twice or get skipped during Daylight Saving Time?
System crontabs running in a local timezone with DST transitions experience a repeated 01:00–01:59 hour in autumn and a skipped 02:00–02:59 hour in spring. Running schedulers in UTC avoids DST discontinuities entirely.
What does the 's' mean in drwxr-sr-x (mode 2755)?
That is the setgid (2000) bit on a directory: new files and subdirectories created inside it automatically inherit the directory's group ownership rather than the creator's primary group.