Created
May 17, 2017 13:23
-
-
Save withakay/82475e09211d9508d211a7c1e30ef82f to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
# A quick and dirty script to add one users groups to another | |
# Tested on Ubuntu 16.04 | |
if [[ -z "$1" || -z "$2" ]]; then | |
echo "USAGE:" | |
echo " ./clonegroups.sh <source_user> <dest_user>" | |
exit 0; | |
fi | |
SOURCE_USER="$1" | |
DEST_USER="$2" | |
for i in `groups $SOURCE_USER` ; do | |
if [[ "$SOURCE_USER" != "$i" ]] && [[ "$i" != ":" ]] ; then | |
addgroup $DEST_USER $i | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment