LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to change user group ? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-user-group-181149/)

Menestrel 05-13-2004 02:39 PM

how to change user group ?
 
what command from the CLI should I run to change the group a user is in ?

TheOther1 05-13-2004 02:42 PM

usermod:

-(~:#)-> usermod
usage: usermod [-u uid [-o]] [-g group] [-G group,...]
[-d home [-m]] [-s shell] [-c comment] [-l new_name]
[-f inactive] [-e expire ] [-p passwd] [-L|-U] name

jschiwal 05-13-2004 11:18 PM

Given the parameters $user and $grp, this line will give you a comma seperated list of groups that the user will belong to after $grp is removed. I believe that is what the -G option needs.
Code:

groups $user | sed  -e "s/$user\ ://" -e 's/ $grp//' -e 's/\ /,/g'
The line uses the groups command to print a groups of lists that the user belongs to. It is of the form:
user : group1 group2 ...

the sed command removes the initial 'user :' , removes the group from the list (as well as a leading space, and lastly replaces the spaces with commas.

comprookie2000 05-14-2004 10:51 AM

If you just wanted to add a user to a group;
bash:~# adduser whoever src
adding user whoever to group src...

Menestrel 05-15-2004 02:58 PM

thank you all for the quick answers. I also found out that I can edit the /etc/group file. is that correct?

I have one more question. About the default user groups that are created on linux. How can I find what rights has each group ?

urka58 05-16-2004 04:29 PM

Groups do not refer to any permission right.
Permissions are "features" of files.
ie
ls -l output can be something like
-rw-r--r-- 1 root group1 5166 Apr 24 22:53 lspci.txt
where
leading - means it is a normal file
rw- means root has read write permissions
r-- means group1 has read permission
r-- means others have read permission

In this case the user "user1" included into "group1" group will have only read permission
Hope this helps
Ciao

Menestrel 05-20-2004 07:33 PM

but what if two groups have different permissions on a file, who can I see what each group can do to a file ? if i want group1 and group 2 to have read permissions group3 to have read and write permissions and group4 and group5 to have read write and execute permissions. Can I make these settings ? if I can, how could i view these settings ?

TheOther1 05-20-2004 11:09 PM

Maybe this will help clear things up.


All times are GMT -5. The time now is 09:18 PM.