Skip to content

Instantly share code, notes, and snippets.

@withakay
Created May 17, 2017 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save withakay/82475e09211d9508d211a7c1e30ef82f to your computer and use it in GitHub Desktop.
Save withakay/82475e09211d9508d211a7c1e30ef82f to your computer and use it in GitHub Desktop.
#!/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