Solved Two or more permission groups for a file?

Solved issue

Bagheera

Member
Joined
Sep 2, 2024
Messages
31
Reaction score
12
Credits
281
I've currently got XAMPP installed (Apache webserver emulation coupled with Perl, Php, MariaDB) and I wish to modify its configuration file (httpd.conf)

Trouble is as well as 'root' being the owner, 'root' is also the group and everyone else including my user login only has read permission, not write. Yes I could apply 666 to the file permissions but consider that a bad habit to get into. Instead I'd like to create a new user group called 'xampp', and assign that group to the httpd.conf file with RW permissions. If my user id then joins that group presumably I'll then be able to modify that file.

My question is, can you have more than one user group assigned to a file and if so, what is the command and syntax to do so?
 
Last edited:


You can only use one group in the primary permissions, but you can add group access to a file or directory using ACLs. See setfacl(1). Make sure you mount your file system with ACLs enabled.

Signed,

Matthew Campbell
 
Thank you again Matthew. If my file system wasn't mounted with ACLs enabled would that mean re-installing my Linux?

Otherwise, presumably I could with root access, remove the 'root' group from the file in question, and then add a newly created xampp group? I'm wondering why XAMPP themselves would have distributed their config file with 'root' quoted as the group as well as the owner?
 
Just use the -o acl option, along with any other mount options in a comma separated list when mounting the drive. You could try adding it to /etc/fstab.

Use /usr/bin/chgrp to change the group ownership to a different group.

Signed,

Matthew Campbell
 
Does that seem a bit strange to you Matthew, that the configuration file in xampp has 'root' assigned as both the group as well as the owner?

For simplicity think I'll create a new group called 'xampp', add myself to that group and then replace root as the file's group with 'xampp'. Hopefully that'll work.

You're a wealth of Linux knowledge Matthew ... how long ago roughly did you start with it?
 
Last edited:
Does that seem a bit strange to you Matthew, that the configuration file in xampp has 'root' assigned as both the group as well as the owner?

For simplicity think I'll create a new group called 'xampp', add myself to that group and then replace root as the file's group with 'xampp'. Hopefully that'll work.

You're a wealth of Linux knowledge Matthew ... how long ago roughly did you start with it?
I started using Linux back in the mid 90s. I've been using Debian since mid 2020. I had a Unix and C class in college using an Ultrix. Many files on a Linux system use root:root. I use root:web for my web server. This way root owns the files and directories and the web group has read/search access so if the server gets hacked it doesn't have authority to screw itself up. My main ordinary user is also in the web group.

I'm just glad I could be helpful to you.

Signed,

Matthew Campbell
 
In Linux, a file can only have one primary group assigned to it. However, users can belong to multiple groups, which allows them to access files associated with any of those groups.

To change the group ownership of a file, you can use the chgrp command. Here's the syntax:

Code:
 chgrp <groupname> <filename>

If you need to change both the owner and the group at the same time, you can use the chown command:

Code:
 chown <newowner>:<newgroup> <filename>

For example, to change the owner to user1 and the group to group1 for a file named example.txt, you would use:

Code:
 sudo chown user1:group1 example.txt
 
In Linux, a file can only have one primary group assigned to it. However, users can belong to multiple groups, which allows them to access files associated with any of those groups.

To change the group ownership of a file, you can use the chgrp command. Here's the syntax:

Code:
 chgrp <groupname> <filename>

If you need to change both the owner and the group at the same time, you can use the chown command:

Code:
 chown <newowner>:<newgroup> <filename>

For example, to change the owner to user1 and the group to group1 for a file named example.txt, you would use:

Code:
 sudo chown user1:group1 example.txt
I was pointing out that ACLs allow access to specific users or specific groups beyond what primary group access provides.

Signed,

Matthew Campbell
 
Creating an 'xampp' user group and assigning myself to that group (both using Mint's GUI), then using sudo chgrp to change configuration file's permission group from 'root' to 'xampp' has worked perfectly. Modified configuration file now successfully saved :)

Thank you again Matthew and dos2unix for sharing your knowledge, advice and tips.
 
Don't forget to edit your first post and mark this as solved.

Heh... It's one of those "bear necessities of life"... (At least you'll know what I'm on about.)
 
'Tis done KGill. You can ... "forget about your troubles" now.
 
You just hit the 'like' option this morning. I've had an earworm ever since I got said notification.

That ol' bear was rather Buddhist in his outlook. "Forget about your worries and your strife."

Also, that's probably good advice when it comes to picking a prickly pear. Don't use your paw, use your claw. That's sound advice, I suppose.

If I'm gonna have the earworm, everyone's gonna have the earworm!

I actually saw the movie at a drive-in. I was an adult but still went to see it. I dimly recall taking a female who had a kid but that was a long time ago and those memories are suspect.
 

Members online


Top