If you’re lazy about permissions,
chown both take a
--reference flag to set permissions equal to those of another file.
chmod --reference=file/with/good/permissions file/with/permissions/to/fix
This comes up for us in a Rails app that we generally run in a Docker container. When we
bin/rake generate migration, the new migration file is owned by
root, which is annoying. A better next step might be to stop running the app inside a container in dev, but that’s a different piece of work altogether.