chmod

Change file mode bits. Used to control who can read, write, or execute a file.

Synopsis

chmod [options] mode file(s)

Core Options

-R

Change files and directories recursively.

u

User (owner) permissions.

g

Group permissions.

o

Others permissions.

a

All users (u, g, and o).

Usage Examples

Make Executable

Allow the owner to execute the file.

chmod u+x script.sh

Standard Web Permissions

Files 644 (rw-r--r--), Directories 755 (rwxr-xr-x).

chmod 644 index.html

Full Permissions (Dangerous)

Give everyone read, write, and execute permissions.

chmod 777 data/

Remove Write Permission

Prevent group and others from writing.

chmod go-w file.txt

Recursive Change

Change permissions for a directory and everything inside it.

chmod -R 755 /var/www/html
Built for builders.