chmod 4755 (rwsr-xr-x) explained

The owner can read, write and execute; the group can read and execute; others can read and execute.

Octal
4755
Symbolic
rwsr-xr-x
ls -l shows
-rwsr-xr-x

Who can do what

Class Read (4) Write (2) Execute (1) On a directory
Owner (u)YesYesYesList the files. Enter it and open files inside. Create, rename and delete files.
Group (g)YesNoYesList the files. Enter it and open files inside.
Others (o)YesNoYesList the files. Enter it and open files inside.

When to use chmod 4755

Gives the owner full access and others read and execute, plus the setuid bit: the program runs with the permissions of the file's owner, not of the user who starts it.

How passwd and sudo work: they are owned by root and setuid, so ordinary users can run them with root privileges. Setuid on your own programs, and especially on scripts, is a serious security risk.

Special bits

  • Setuid (4): an executable runs with the permissions of the file's owner instead of the user who started it.

Commands

Set the mode with octal digits, or with the equivalent symbolic form:

chmod 4755 path/to/file
chmod u=rwx,g=rx,o=rx,u+s path/to/file

To apply it to every directory below a folder (and not to the files), combine it with find:

find path/to/folder -type d -exec chmod 4755 {} +

chmod -R 4755 changes files and directories alike, which is rarely what you want: directories usually need execute, regular files usually should not have it.

Work out any mode in the Chmod Calculator