Skip to content

chmod command

Change file and directory permissions.

On this page

Syntax

chmod [options] mode file…

Provided by the coreutils package. Run man chmod for the full manual.

Common options

OptionWhat it does
-RApply recursively
-vPrint each change
u g o aUser, group, others, all
+ - =Add, remove or set permissions
r w xRead (4), write (2), execute (1)

Examples

  1. Make a script executable

    chmod +x deploy.sh
  2. Owner read/write, others read

    chmod 644 index.html
  3. Owner full, others read and execute

    chmod 755 /usr/local/bin/tool
  4. Private file

    chmod 600 ~/.ssh/id_ed25519
  5. Remove write for group and others

    chmod go-w file.txt
  6. Directories 755 and files 644

    find /var/www -type d -exec chmod 755 {} + -o -type f -exec chmod 644 {} +
  7. Recursive change

    chmod -R 750 /opt/app

Tips

  • Avoid chmod 777; give the web server user ownership instead.

chmod guides

← All Linux commands · Suggest a fix

Back to top