>_ IzzyLab

Hands-on task

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

Lock down the password file

easy~2 min

The file /etc/billing/db.env with the database password is currently readable and writable by everyone. Set its permissions to 640: the owner reads and writes, the group only reads, others get nothing.

What you'll practise:
  • chmod
  • octal notation
  • file permissions
  • secrets in files

Topic breakdown

File permissions are three triplets of bits: for the owner, the group and others. Each triplet is a sum of r=4, w=2, x=1, so 6 is rw-, 4 is r--, and 0 is nothing. Files with passwords and keys must not be accessible to "others": any process on the server running under someone else's account could read them. Permissions are changed with chmod; ls -l and stat -c %a show the current ones.

What's checked

  1. db.env is in place
  2. db.env permissions are 640

What it looks like