Force files and subdirectories to have a specific owner and group

It may be worthwhile to force all files under a specific directory to have the same user and group. You can do that using the sticky flag.


Especially for web servers (where the web server and application server may run under different users, and to complicate, the CLI user may also run under a different user),
it may be worthwhile to force all files under a specific directory to have the same user group. You can do that using the sticky flag.


sudo chmod g+s ~/my_dir
// change existing ownership
chown -R www-data:www-data ~/my_dir