Cheat sheets

File permissions: chmod and chown explained

Read, change and fix permissions for files and folders, including everything inside a folder.

Handy? Press ⌘ DCtrl + D to bookmark this page for next time.

Fill these in once
  1. See the permissions
    Terminal
    ls -l my-folder

    r = read, w = write, x = run. As numbers: 7 = rwx, 6 = rw, 5 = rx, 4 = r.

  2. Make a script runnable
    Terminal
    chmod +x my-folder
  3. Give a folder sensible permissions (folders 755, files 644)
    Terminal
    find my-folder -type d -exec chmod 755 {} +
    find my-folder -type f -exec chmod 644 {} +
  4. Make yourself the owner of a folder and everything in itNeeds sudo
    Terminal
    sudo chown -R $USER:staff my-folder
  1. See the permissions
    Terminal · Ubuntu / Debian
    ls -l my-folder

    r = read, w = write, x = run. As numbers: 7 = rwx, 6 = rw, 5 = rx, 4 = r.

  2. Make a script runnable
    Terminal · Ubuntu / Debian
    chmod +x my-folder
  3. Give a folder sensible permissions (folders 755, files 644)
    Terminal · Ubuntu / Debian
    find my-folder -type d -exec chmod 755 {} +
    find my-folder -type f -exec chmod 644 {} +
  4. Make yourself the owner of a folder and everything in itNeeds sudo
    Terminal · Ubuntu / Debian
    sudo chown -R $USER:$USER my-folder
  1. See the permissions
    PowerShell
    icacls my-folder
  2. Give yourself full control of a folder and everything in itRun as administrator
    PowerShell
    icacls my-folder /grant "$($env:USERNAME):(OI)(CI)F" /T
  3. Take ownership of a folder and everything in itRun as administrator
    PowerShell
    takeown /f my-folder /r /d y