>_ IzzyLab

Hands-on task

This task is step 11 of the course “Users, groups and permissions”

Wiki permissions after an FTP upload

medium~7 min

The wiki was uploaded to /var/www/wiki over FTP, and the permissions came out random: the Site tab above the terminal shows 403 Forbidden instead of the wiki. Fix the permissions recursively: all directories — 750, all files — 640 (other users get no access). nginx runs as www-data and reads the wiki through the group: files are owned by root with group www-data — don't change that. Reload the Site tab — the wiki should open.

What you'll practise:
  • find
  • -exec
  • chmod
  • directory and file permissions
  • recursive traversal

Topic breakdown

Permission bits mean different things on a directory and on a file: x on a directory is the right to enter it and access its contents, while on a file it's the right to run it as a program. That's why a single recursive chmod -R with one mode always breaks one side: either files become executable, or directories can't be entered. The right way is to split objects by type: find picks directories and files separately and applies a mode of its own to each group via -exec. The negation ! -perm helps find whatever isn't fixed yet.

What's checked

  1. all directories are 750
  2. all files are 640
  3. the wiki files are in place
  4. the wiki opens in the browser (nginx reads it through the www-data group)

What it looks like