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: chown --from changes the owner only where the old owner matches, a permissions-safe filter

Permissions
~/tips/tip-permissions-chown-from-old-owner

sudo chown -c -R --from=1000:1000 www-data:www-data /srv/site

Changes the owner of only the files that currently belong to a given user or group.

After a restore or a migration, ids can point to the wrong account. I do not want to touch anything that has a different owner.

sudo chown -c -R --from=1000:1000 www-data:www-data /srv/site

--from=CURRENT_OWNER:CURRENT_GROUP makes chown skip every file that does not match, and -c prints the files that really changed. Either side may be left out, so --from=:oldgroup matches on the group only. The option is GNU specific, so it is not available in the macOS chown. Run it once without -R on a single folder to check the match before the recursive run.

Further reading: chown 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