Ever tried addgroup? For example, to add user 'username' to groups 'foo', 'bar', and 'baz', I believe you just have to: addgroup username foo bar baz