how to change user group ?
what command from the CLI should I run to change the group a user is in ?
|
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 |
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' 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. |
If you just wanted to add a user to a group;
bash:~# adduser whoever src adding user whoever to group src... |
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 ? |
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 |
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 ?
|
Maybe this will help clear things up.
|
All times are GMT -5. The time now is 09:18 PM. |