Linux - NewbieThis 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!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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 ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.