>_ IzzyLab

Hands-on task

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

Which files are read-only

easy~3 min

In the certificate store /etc/certs, private keys must have permissions of exactly 400 (read-only for the owner). Find the regular files with permissions of exactly 400 and write their full paths (sorted) to /root/readonly.txt.

What you'll practise:
  • find
  • -perm
  • exact permission match
  • -type f
  • sort

Topic breakdown

The -perm predicate of find comes in three forms: a number with no prefix — the permissions match bit for bit; with the - prefix — at least the listed bits are set; with the / prefix — at least one of them is set. For the question "which files have exactly these permissions" you need the exact form: -400 would also catch 440 and 600. Together with -type f only regular files are selected, and sorting makes the list reproducible.

What's checked

  1. /root/readonly.txt created
  2. files with permissions of exactly 400 found

What it looks like