brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: sudo -u www-data test -r proves the web server really has the permissions

Permissions
~/tips/tip-permissions-sudo-u-test-access

sudo -u www-data test -r /srv/site/config.php && echo can read || echo blocked

Tests whether another user, such as the web server, can read or write a path.

Guessing whether a service account can read a file wastes time. I let that account run the test itself.

sudo -u www-data test -r /srv/site/config.php && echo can read || echo blocked
sudo -u www-data test -w /srv/site/cache && echo can write

test -r, -w and -x ask the kernel for the real answer, for that user, including groups and ACLs. Combine it with namei -l to find the folder in the way. It works for accounts without a login shell, because sudo does not start one for a single command.

Further reading: sudo manual page

More Permissions tips sudo su -s /bin/bash www-data sudo setfacl -R -d -m g:media:rwX /srv/media sudo cp -r /srv/site /srv/site.r ls -ln /srv/data newgrp media All Permissions tips (30) All topics

Link