Created
October 11, 2022 18:47
-
-
Save aimfireready/be28f25fecd38bbd4c42fbbe5b179062 to your computer and use it in GitHub Desktop.
Copy bash groups from model user to target user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This script will take the groups of the current user. | |
| # Usage: 'clone-groups wesley' | |
| $targetUser=$1 | |
| target=$(for i in $(groups);do echo "$i,";done) | |
| #Remove final character to remove the extra ',' at the end of the string | |
| target=${target%?} | |
| unspaced=$(echo $target | sed 's/ //g') | |
| sudo usermod -aG $unspaced $targetUser | |
| groups $targetUser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment