breakitdown

chmod +x

Answer

chmod +x file adds the execute bit so the file can be run directly, as ./file. With no u, g, o or a in front, GNU chmod adds execute for everyone except where your umask blocks it, so a 644 file usually becomes 755.

chmod +x on common starting modes

Computed with the umask at 022, the usual default. Checked against GNU chmod on real files.

BeforeTypeAfter
644file755 rwxr-xr-x
600file711 rwx--x--x
755directory755 rwxr-xr-x
700directory711 rwx--x--x

What to know

When the clause has no who-letter, chmod behaves like a+x but leaves alone any bit that is set in the umask. With the common umask 022, execute is not masked, so all three classes get it: 644 becomes 755. With umask 077, only the owner gets it: 644 becomes 744.

To be explicit, name the class: chmod u+x (only you), chmod ug+x, or chmod a+x (everyone, regardless of umask).

Execute alone is not enough for a script to run: it also needs a first line such as #!/bin/sh or #!/usr/bin/env python3, or the shell will not know which interpreter to use.

Where it fits

Gotchas

Related explainers

← chmod calculator