-   Linux - Newbie (
-   -   Changing the 'default' group when creating files (

gentooox 10-27-2007 04:24 PM

Changing the 'default' group when creating files
When a user is a member of more than 1 group, which setting determines what group is used when creating files and directories?
Ex.: user A is member of the groups 'cats' and 'dogs'. When he creates a file, user A is the owner, and per default, 'cats' is used as the owning group. 'cats' is always used. How can I change this to always being 'dogs' instead?
Thanks for your time :)

saikee 10-27-2007 04:48 PM


usermod -g dogs <username>

matthewg42 10-27-2007 04:51 PM

It is the main (primary) group for the user. You can temporarily switch the primary group to one of the auxiliary groups using the sg command in terminal, in much the same way that you can switch to another user using su. For example:

% groups
matthew adm dialout cdrom floppy audio dip video plugdev scanner fuse lpadmin admin netdev powerdev
% touch file1
% sg adm
% touch file2
% exit
% touch file3
% ls -l file?
-rw-r--r-- 1 matthew matthew 0 2007-10-27 22:49 file1
-rw-r--r-- 1 matthew adm    0 2007-10-27 22:50 file2
-rw-r--r-- 1 matthew matthew 0 2007-10-27 22:50 file3

gentooox 10-27-2007 04:56 PM


Originally Posted by saikee (Post 2939101)

usermod -g dogs <username>

That did it, thanks a lot!

All times are GMT -5. The time now is 05:50 AM.