I wrote a snippet at work today for the following scenario: we have an environment at work where websites are owned by separate users and groups. In order to modify files in the site directories, our usernames must belong to these groups. It’s a pain to manually add oneself to these groups, especially when new sites are being created all the time. This script runs through all the groups on the server following the standard pattern for our website users groups (using regex) and adds the user running the script to these groups. The script displays verbosely what groups are to be added and the user expressly gives permission prior to performing any actions.