openHAB won't write to /home/openhabian

I’m running my OH2.2 on RPi and try to write some files to /home/openhabian/webcam

[22:02:04] openhabian@openHABian:~$ ls -la
insgesamt 60
drwxr-xr-x 6 openhabian openhabian 4096 Jan  6 15:42 .
drwxr-xr-x 3 root       root       4096 Nov 29 03:37 ..
-rw------- 1 openhabian openhabian 7459 Jan  6 15:42 .bash_history
-rw-r--r-- 1 openhabian openhabian  220 Nov 29 02:22 .bash_logout
-rw-r--r-- 1 openhabian openhabian 2424 Dez 25 18:43 .bash_profile
-rw-r--r-- 1 openhabian openhabian 3523 Nov 29 02:22 .bashrc
drwxr-xr-x 2 openhabian openhabian 4096 Dez 25 20:54 .nano
-rw-r--r-- 1 openhabian openhabian  675 Nov 29 02:22 .profile
-rw-r--r-- 1 root       root         89 Dez 25 18:49 README.txt
drwx------ 2 openhabian openhabian 4096 Dez 25 20:56 .ssh
drwxr-xr-x 4 openhabian openhabian 4096 Dez 25 18:49 .vim
drwxr-xr-x 2 openhabian openhabian 4096 Jan 20 21:59 webcam

everytime I want to save a JPG from my Webcam, the file stays 1KB and won’t load => /tmp works - but I can’t mv or cp the file there…? Did I miss something?

I may be wrong, but I think the openHAB user is openhab, not openhabian. So it’s obvioius that openHAB can’t write to the home directory of openhabian. The user openhab has no home directory at all.

The user is indeed openhabian and it’s home Directory is /home/openhabian:

[20:07:28] openhabian@openHAB2:~$ cd ~
[20:08:32] openhabian@openHAB2:~$ pwd
/home/openhabian

I can execute files within this directory from inside openHAB, so I figured, I could also have write access… (at least the write right is set for the ~/webcam directory…

And this is the user, that runs openhab?

This line show’s that only the Owner have Permission to write in this directory.

You must differ 2 Users… if you logged in via ssh as openhabian … this is not the User that runs Openhab! openhabian is the System User…

The User Openhab runs Openhab2 … and the User Openhab has no permission to write in the Home Directory of Openhabian …

1 Like

Show us your Script / Rule or whatever that doesn’t work … that we can fix your Problem :slight_smile:

just as Udo an you suggested: I assumed, the openhabian user also runs openHAB, but it’s openhab indeed.
after changing permissions on ~/webcam/ it works. Thank you both!

Actually, openhab does have a home. Its /var/lib/openhab2 for installed OH.

Ah, was that changed lately?

That has been the case as long as I’ve been using OH, at least as far back as 1.7 I think.

Ah, I see… mixed that up eventually with “no login” :slight_smile:

Indeed. The openhab account is configured to prevent logins. But it is pretty handy to know that openhab’s home directory is the userdata folder. Then you can do things like

tail -f ~openhab/logs/openhab.log

:slight_smile:

I remember learning this the hard way back when. For a time the OH start script would change the permissions on ALL files and folders remotely related to OH. As a consequence shell scripts stored in ~openhab/bin would have their execute bit stripped every time OH restarted.

And for future readers, if you have shell scripts you want to execute from OH using Exec bindingin or executeCommandLine, ~openhab/bin is a better location than /etc/openhab2/scripts, the latter of which is intended for Rules scripts, not shell scripts.

1 Like

Yes, that’s an important point. And of course, if someone wants to provide ssh keys to allow openHAB to control some other computers, one would only need to add ~/.ssh/ to have a perfect place to store the keys.

2 Likes