If you’re lazy about permissions, chmod and 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.
@misc{Pittman201712C,
author = {Pittman, Cameron},
title = {Copy permissions},
journal = {Hurtling through Space},
url = {},
year = {2017},
month = {December},
accessed = {Oct 17, 2022}
}