I am trying to grant users read-only access to directory (conf) contents, so I added a user(dev1) to a group (tomcat) and set the group permission to g+r.
I have the following user:group
1) tomcat:tomcat
2) dev1:developers
I have the following file and directory permissions:
dev1@athena:~$ ls -la /opt
drwxr-xr-x 6 root root 4096 May 26 11:24 .
drwxr-xr-x 19 root root 4096 May 20 15:09 ..
drwxr-xr-x 9 tomcat tomcat 4096 May 26 10:34 apache-tomcat-10.1.9
lrwxrwxrwx 1 tomcat tomcat 25 May 26 11:24 tomcat -> /opt/apache-tomcat-10.1.9
dev1@athena:~$ ls -la /opt/tomcat/
drwxr-xr-x 9 tomcat tomcat 4096 May 26 10:34 .
drwxr-xr-x 6 root root 4096 May 26 11:24 ..
drwxr----- 3 tomcat tomcat 4096 May 26 16:02 conf
dev1@athena:~$ sudo ls -la /opt/tomcat/conf
drwxr----- 3 tomcat tomcat 4096 May 26 16:02 .
drwxr-xr-x 9 tomcat tomcat 4096 May 26 10:34 ..
-rw-r----- 1 tomcat tomcat 1411 May 9 14:30 context.xml
-rw-r----- 1 tomcat tomcat 6985 May 26 10:57 server.xml
-rw-r----- 1 tomcat tomcat 172391 May 9 14:30 web.xml
Note: I deleted some ls entries for brevity.
I configured dev1 to be a member of the tomcat group and verified, like so:
dev1@athena:~$ sudo usermod -aG tomcat dev1
dev1@athena:~$ groups
developers sudo tomcat
dev1@athena:~$ id
uid=1002(dev1) gid=1002(developers) groups=1002(developers),27(sudo),1001(tomcat)
I have logged out and login as dev1 and even restarted the VM.
However, when I try to open server.xml using vi, I get a Permission Denied error
dev1@athena:~$ vi /opt/tomcat/conf/server.xml
...
"/opt/tomcat/conf/server.xml" [Permission Denied]
When I try to list the contents of /opt/tomcat/conf, I also get Permission Denied error.
ls -la /opt/tomcat/conf
ls: cannot open directory '/opt/tomcat/conf': Permission denied
What permission did I miss to allow dev1 read-only access to the contents of /opt/tomcat/conf directory? Have I misunderstood Linux file permissions?
Additional info:
Version: Ubuntu Live Server 22.04.2
VM: VMWare Fusion 13.0.0
OS: Macos (M1) Monterey
Any help will be greatly appreciated.
Thanks in advance.