Make a script executable
Adds the executable permission bit to a script for its owner, group and others alike, without touching any of its existing read/write bits.
Last updated
chmod +x deploy.sh
How it works
The symbolic form +x adds the executable bit for all three permission classes — owner, group, and others — at once, leaving whatever read and write bits were already set exactly as they were. That's the main reason to prefer it over an absolute octal mode like chmod 755: 755 REPLACES the entire permission set with specific values, which can silently change bits you didn't intend to touch if the file's existing permissions weren't already 644.
Once set, ./deploy.sh runs the file directly instead of needing bash deploy.sh — the shell resolves the leading #! (shebang) line to know which interpreter to launch it with.
Watch out for
- →+x alone doesn't make a script runnable without a shebang line (#!/bin/bash, #!/usr/bin/env python3, etc.) at the very top — without one, ./deploy.sh fails because the OS has no way to know which interpreter should handle it.
- →To grant execute permission to just yourself rather than everyone, use chmod u+x deploy.sh instead of the broader +x shown here — worth doing for anything containing credentials or logic you don't want other local users running.
- →This has no equivalent on native Windows filesystems (NTFS has no Unix permission bits at all) — under WSL or Git Bash the bit is tracked, but it doesn't reliably survive a copy back out to native Windows tooling, where executability is inferred from the file extension instead.