Access rights problems with pi user

I dont have access to /etc/openhab2/ folder when logged on with pi user.
I get access denied. When i change ownership to pi i can access the folder but then i get errors when intalling a binding or something else.
Is ther no way on the raspberry pi to give two users access to the same foldeR?

Yes, Linux makes use of user groups for that functionality. That is separate from the openHAB software though.

Why not use the openhabian image? It has all these types of issues fixed.

You may just need to add the pi user to the openHAB group.

How did you install OH ? Mine is installed via deb package and the permissions of that folder are:

ls -ld /etc/openhab2
drwxr-xr-x 17 openhab openhab 4096 Apr 10  2020 /etc/openhab2

This leads to how / what are permission on a Linux system ?
As you can see there are 10 characters at the beginning of the line and two times the word openhab.
The first one stands for the user and the second one for the group a file or directory belongs to.
A file/directory is owned by one user. A user can belong to at least one ( default ) group and can be added to more groups.
If first character is a d then it shows that the related items is a directory. In case it is a - the item is a
file.
Next characters can be divided into groups of three characters ( rwx rwx rwx ).
The first one stands for the owner, next one for the group the file/directory belongs to and the last one for world / also called all others.
In case the related r is shown/active in the listing it means the related part of the character group has read access; w then stands for write access and x for execute access ( x is needed to list content of a directory and to execute a file ( e.g. a binary or script ).

What would you like to do ?
Execute something ? Write something ? List something ?

Processes also run with a specific users ownership and group. These processes have access to files and directories according to the above described permissions. That means in case a process does not belong to a specific group but needs to write to a directory/file then the dirctory/file needs to provide write access for all others / world. That means in theory you can provide rwx for world and you are done. Everyone can access the file/directory, can write to it and can execute it. But think about it. Is this really what you would like to achieve ? On one hand yes it is the easiest to not get any error message. On the other hand these permissions were introduced to make your system more secure. You can hide stuff from other users eyes ( they do not have access to read a file ); they cannot write/overwrite your stuff and not execute a file.

Read and understand the above and you find different solutions for it:
a) access the file/folder with the permissions of the user that owns the file/folder
b) add the user to an other group
[EDIT]
and make the directory writeable for the group
[/EDIT]
c) open a root shell ( this means become user root ); that user is allowed to access everything ( as long as not SE-Linux is used but that’s another story )
d) open the directory with world permissions and give rwx to everyone
Depending on what you would like / need to achieve a to d can be rated from ideal to least ideal to be done.

Even if the pi user were in the proper group they would not be able to change any files in that directory. The group does not have write permissions.

The OH documentation says you need to learn some Linux to use OH on Linux. This is one of those cases where you need to learn Linux and this forum is not the best place to do that.

thanks, of course. Although my description explains exactly that it’s missing in the solutions description. That’s corrected now.

2 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.