Skip to content

Instantly share code, notes, and snippets.

@aimfireready
Created October 11, 2022 18:47
Show Gist options
  • Select an option

  • Save aimfireready/be28f25fecd38bbd4c42fbbe5b179062 to your computer and use it in GitHub Desktop.

Select an option

Save aimfireready/be28f25fecd38bbd4c42fbbe5b179062 to your computer and use it in GitHub Desktop.
Copy bash groups from model user to target user
# 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