Change file permissions with chmod

Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.

LinuxFilesTerminalsecurityMedium risk
Run chmod u+x script.sh to make script.sh executable for its owner, then run it with ./script.sh.

01Command

Command
$ chmod u+x script.sh

02What it does

Symbolic mode is 'who + operator + permission': u (owner), g (group), o (others), a (all) combined with +, -, or = and r, w, x — for example go-w removes write from group and others. Octal mode sets all bits at once: 755 = rwxr-xr-x (owner full, others read/execute), the usual choice for scripts and directories, while 644 is typical for data files. Use -R to recurse (chmod -R u+rwX dir gives X only where already warranted), and verify the result with ls -l or stat. x on a directory means 'may enter/traverse', not 'may run'.

03Risk

RiskMedium risk
RequirementsYou must own the file (or be root) to change its permissions
!Warning: chmod -R 777 is almost always wrong: it makes every file world-writable, which breaks SSH keys and is a security hole — grant only the permissions actually needed.

04Undo

Undo
$ chmod u-x script.sh

05Sources

  • chmod(1) — change file mode bits
    man7.org · technical · 2026-09-17
    Evidence: The chmod man page describes both symbolic modes like u+x (who operator permissions) and octal modes like 755 for setting mode bits.

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions