From 169df3e84d4c431a8a67327cea6c08cb51a436fa Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 24 Feb 2018 18:34:55 -0800 Subject: [PATCH] also rename user's group --- scripts/rename_user.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/rename_user.py b/scripts/rename_user.py index 9e657e7..bbb0213 100755 --- a/scripts/rename_user.py +++ b/scripts/rename_user.py @@ -9,6 +9,8 @@ import subprocess def rename_user(old_username, new_username): """Given an old and a new username, renames user on disk with usermod. Raises if the usermod call fails.""" + + # Rename user args = [ 'usermod', '-l', @@ -20,6 +22,15 @@ def rename_user(old_username, new_username): ] subprocess.run(args, check=True) + # Rename their group + args = [ + 'groupmod', + '-n', + new_username, + old_username + ] + subprocess.run(args, check=True) + def main(argv): if len(argv) < 3: