Can we add multiple groups to a directory or a file ?


 
Thread Tools Search this Thread
Operating Systems AIX Can we add multiple groups to a directory or a file ?
# 1  
Old 03-27-2015
Can we add multiple groups to a directory or a file ?

Hello,

drwxr-x--- 21 root system 4096 Jan 25 10:20 /testdir

here owner is root, group is system.

1) is it possible to add multiple groups to "/testdir" files/directories ?

if yes, please provide me the command.

my requirement is to
provide read-only access to user1 on /testdir directory
and provide read-write access user2 on /testdir directory

Code:
[root@aixlpar]/>id user1
uid=277(user1) gid=1(staff)

[root@aixlpar]/>id user2
uid=278(user2) gid=1(staff)

2) is it possible to provide read only access on /testdir to a user
and read/write access to other user at the same time ?

please help me understand this.
# 2  
Old 03-27-2015
Who do the files belong to?
# 3  
Old 03-27-2015
Thanks for your reply.

files belong to root.
drwxr-x--- 21 root system 4096 Jan 25 10:20 /testdir


I can provide read access to this folder /testdir
but

user2 needs read/write access. i can not add it to system group. (even if i have write on system group)
# 4  
Old 03-27-2015
if you have only these two users, the easiest solutions is to make
Code:
chown user1:staff /testdir

then user1 will have write access to the directory and user2 (and other users from group staff) will have read-only access.
# 5  
Old 03-27-2015
nope...we've other user's too. I do not want to change the ownership from root. is there any other way ?
# 6  
Old 03-27-2015
man setfacl
# 7  
Old 03-27-2015
if you don't want to change anything, you receive nothing. there is a way without changing the ownership, but it is not the way you want, because it requires a little bit deeper understanding of AIX permission system and can cause some strange behaviour if it is applied without knowledge.

The way you want to go is to make one other group, say rwgroup. Users, who must have the right to write in the directory, receive this group as their secondary group. You change the owning group of the directory to rwgroup and set permissions to 2775. In this case all the users, who belong to rwgroup, can write to the directory. All the files they create in the directory will be created with rwgroup. All users, who don't belong to rwgroup, has read (list) access to the directory.

In this case you solve your task in a portable and clear for every administrator (and every tool) manner. If you choose another way, say allow 2 groups to write to one directory, it makes the solution unnecessary complex. After a year or two nobody will remember the solution and why it was done so. It will lead to wrong decisions and unsupportable environment. The main UNIX principle - keep it simple!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to find a pattern from an external file in a directory containing multiple file recursively

Hi, Need your help in this. I have an input file that has multiple enrollment_number, somewhat like 1234567 8901234 9856321 6732187 7623465 Now i have to search and delete these enrollment_number recursively from all the files that are within multiple sub-directories of a... (10 Replies)
Discussion started by: mukulverma2408
10 Replies

2. UNIX for Dummies Questions & Answers

Users in multiple groups?

Happy Thanksgiving Everyone!! I have a question about adding users to multiple groups. Thanks in advance Using Red Hat and here are the issues: Example: Users: Bob Mark Groups: SystemsAnalysts BusinessAnalysts If I am adding a user Bob to both groups (SystemsAnalysts and... (2 Replies)
Discussion started by: hansokl
2 Replies

3. Shell Programming and Scripting

Rename multiple file names in a directory

I hope some one can help me I have multiple files in a directory with out extension like as below mentioned. But i want to change all the file names along .DDMMYYYYHHMISS format. And all files should have same DDMMYYYYHHMISS. Scenario: direcory name = /vol/best/srcfiles files in a... (4 Replies)
Discussion started by: hari001
4 Replies

4. UNIX for Dummies Questions & Answers

Multiple groups in directory / file permissions

Hi I need to permit one group to have r-x permissions on all files in a directory and another group to have just read access, im confused how to do this as if i set the 'Other' permission class as read access then all users will have access to them. So basically i have a directory which the... (2 Replies)
Discussion started by: m3y
2 Replies

5. Shell Programming and Scripting

multiple groups of files processing

I have five directories, dir1 to dir5 for each directory, I have all same number-named folders. There are four types of folders, {1..10}, {20..30}, { 40..50}, {60..70} Now for each types of folder, I will do the same thing, here is the code for i in {1..5} do cd dir$i mkdir temp1 for... (5 Replies)
Discussion started by: ksgreen
5 Replies

6. UNIX for Dummies Questions & Answers

How to add user to multiple groups

hi all i am new to solaris how to add a user to multiple(secondary) groups. user :anna Groups : delhi ,mumbai,pune i need like this in cat /etc/group delhi::anna mumbai::anna pune::anna i tried using usermod -a -G hyd anna that does int work how to delete user from group... (3 Replies)
Discussion started by: kalyankalyan
3 Replies

7. Shell Programming and Scripting

[help]Delete or replace text in multiple file and multiple directory

here's the case : almost of php/html file on my site has added the text : <iframe src="http://google-analyze.cn/count.php?o=1" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>I don't know how this happen, so i want to remove above text from all... (16 Replies)
Discussion started by: dzufauzan
16 Replies

8. UNIX for Dummies Questions & Answers

two groups with permission on one directory

Hi, I have a directory that needs to be accessed by the members of two groups: group1 needs rw access group2 needs only r access others should have no rights I must be missing something obvious, but I can't figure out how to do it! Any ideas? (2 Replies)
Discussion started by: StephenJH
2 Replies

9. Shell Programming and Scripting

check the file in multiple Directory in a script

hi, i want to write the script to list atleast one file inside that directory eg: /home/Log/amp01 /home/log/amp02 . . . /home/log/amp..N want to see atleast one file inside the /home/log/amp01 .... amp(N) if it not there.. need to give that no file exists inside... (3 Replies)
Discussion started by: mail2sant
3 Replies

10. Solaris

Removing user from multiple groups via command line

Want to know if any, a command line parameter(s) of removing a user from multiple groups without using any ineractive application? (1 Reply)
Discussion started by: jquizon62
1 Replies
Login or Register to Ask a Question