View Full Version : usermod syntax
bluesdog
08-17-2006, 02:40 AM
I can't remember how to do this..
When adding an existing user to another group, the -a switch supposedly appends the group, without deleting the existing groups.
For example, if I want to add user elvis to the video group, if I just type usermod -G video elvisthe other groups are removed.
I know I can list all the other groups: usermod -G video,audio,cdrom,etc. but according to the manpage:-a, --append GROUP
Add the user to the supplemental group.
The problem is, I don't seem to be able to come up with the exact, correct syntax.
danieldk
08-17-2006, 03:38 AM
# groups daniel
daniel : daniel
# usermod -a -G wheel daniel
# groups daniel
daniel : daniel wheel
uteck
08-17-2006, 11:51 PM
You could just modify the /etc/group file directly, that's all the usermod command does.
bluesdog
08-18-2006, 01:33 AM
# groups daniel
daniel : daniel
# usermod -a -G wheel daniel
# groups daniel
daniel : daniel wheel
Ok. Now that's weird. I tried that exact syntax before I posted, and it didn't work. I just tried again and it did.
Maybe the computer is posessed.
Thanks, daniel. At least I know I'm not losing my mind completely... :/
bhobjj
08-18-2006, 10:39 PM
Or in Debian you could use the adduser command :
# adduser elvis video
bluesdog
08-19-2006, 12:58 AM
I'm not sure what was going on with the computer I was setting up at the time.
I've been learning command line stuff, for various tasks, mainly because they are usually portable between different flavors of Linux, and I sometimes work with 'buntu, and non-debian distros like centos.
It also impresses the hell out of the microserfs :)
The adduser command is, afaik, for adding new users, whereas usermod alters an existing user's setup.
I've added users to additional groups before, by using the syntax defined by daniel. Example: usermod -a -G video,audio,cdrom login, but for some reason it didn't work, until a day later, when I restarted the machine to complete the setup.
Odd, but we all know computers are strange, whimsical little creatures! :biggrin:
bhobjj
08-19-2006, 05:05 PM
The adduser command is, afaik, for adding new users, whereas usermod alters an existing user's setup.
adduser user group
Add an existing user to an existing group
~~~~~~~~~~~~~
bluesdog
08-20-2006, 03:26 AM
Thankyou :)
Interestingly, that works for adding a user to a single group
[root@debbie:/home/alj]# groups smeg
smeg : smeg
[root@debbie:/home/alj]#adduser smeg dialout
Adding user `smeg' to group `dialout' ...
Done.
... but not to many groups at once
[root@debbie:/home/alj]# adduser smeg windows,camera,scanner
adduser: The group `windows,camera,scanner' does not exist.
Whereas with usermod
[root@debbie:/home/alj]# groups smeg
smeg : smeg dialout
[root@debbie:/home/alj]# usermod -a -G windows,camera,scanner smeg
[root@debbie:/home/alj]# groups smeg
smeg : smeg dialout windows camera scannerSo many commands...:biggrin:
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.