>_ IzzyLab

Hands-on task

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

The metrics service can't write

easy~2 min

The metrics collector runs as the user metrics, but it crashes with Permission denied: after a restore from backup its data directory /var/lib/metrics belongs to root. Make metrics the owner and group of the directory and everything inside it.

What you'll practise:
  • chown
  • chown -R
  • owner and group
  • Permission denied
  • service users

Topic breakdown

Access to a file is determined by its owner, its group and the mode bits. If a service's data directory belongs to another user, the process running under its own account gets Permission denied, even though mode 755 looks fine: only the owner can write under it. The fix is to change the owner with chown, not to tweak the bits with chmod. It has to be done recursively, otherwise nested files and subdirectories stay with the old owner and the service breaks a bit later — on the first old file it touches.

What's checked

  1. directory owner and group are metrics
  2. metrics can write to wal/
  3. everything inside belongs to metrics

What it looks like