Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-27-2007, 04:24 PM   #1
LQ Newbie
Registered: Oct 2007
Posts: 3

Rep: Reputation: Disabled
Question 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

Last edited by gentooox; 10-27-2007 at 04:40 PM.
Old 10-27-2007, 04:48 PM   #2
Senior Member
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
usermod -g dogs <username>
Old 10-27-2007, 04:51 PM   #3
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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
Old 10-27-2007, 04:56 PM   #4
LQ Newbie
Registered: Oct 2007
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thumbs up Solved

Originally Posted by saikee View Post
usermod -g dogs <username>
That did it, thanks a lot!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the default icon for Files with some extention me4linux Linux - Software 2 08-14-2007 02:17 PM
creating a new group for CDRW xucaen Debian 2 09-26-2005 11:24 AM
changing ownership and group of multiple files.. utanja Debian 3 02-21-2005 06:10 PM
Changing a user's default group dogn00dles Linux - Security 4 07-09-2003 03:59 PM
Creating A Group MikeeX Slackware 1 04-25-2002 08:00 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:24 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration