3
It is known that useradd
is used to add new user accounts.
useradd newuser
The -G
flag is used to add groups for respective privileges. Is there a simpler way to create a user will all privileges of a specific existing user?
3
It is known that useradd
is used to add new user accounts.
useradd newuser
The -G
flag is used to add groups for respective privileges. Is there a simpler way to create a user will all privileges of a specific existing user?
2
There may be a cleaner way to do this, but if I understand correctly, this should work:
useradd -G $(groups | tr ' ' ',') newuser
groups gives you a list of the groups the current user (or a different user if specified) belongs to, seperated by spaces. tr converts the spaces to commas, since that is what useradd expects.
Note that this doesn't necessarily place the user in the same "initial login group" as the current user. – agtoever – 2016-07-30T18:45:05.963