This script has to be run as user 'www-data' or as 'root'!
sudo -u www-data nc-who monitor
/usr/local/bin/nc-who: line 60: /tmp/ebtb-logfiles/nc-who.log.lock: Permission denied
When I run as www-data, as suggested above, I get:
/usr/local/bin/nc-who: line 60: /tmp/ebtb-logfiles/nc-who.log.lock: Permission denied
.. loading modules - nc/nextcloud/dev/fd/61: line 67: /usr/local/include/ebtb/prod/fp: Permission denied
When I finally run as root, I get:
.. loading modules - nc/nextcloudPHP Warning: include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning: include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning: Undefined variable $CONFIG in Standard input code on line 6
PHP Warning: foreach() argument must be of type array|object, null given in Standard input code on line 6
thank you for your feedback and sorry for the late response. You didn’t respond in the thread belonging to this script, so I wasn’t notified right away.
The error message actually indicates that the config directory was not passed on correctly.
The only explanation I can think of is that it has something to do with the rights problems you described.
Yes, it’s true, the script should actually be run completely as root the first time so that the path to the nextcloud installation can be written into the script. That is logged here:
I assume that’s where it went wrong.
Could you please check this output:
If it does not show the path to your nextcloud installation, then run this step again:
and start again from scratch as root:
sudo nc-who
Your feedback provides valuable information that shows me where improvements are still needed.
I wanted to make the script run with unprivileged rights if possible. However, since I have implemented a lot of security features like lock files and such, switching from root to unprivileged is no longer as easy as before. So I still have to make some improvements so that it really works on all systems.
I am sory for that. I will fix that soon, so that log- and lockfiles wil no longer be shared between users and to make it clear, that the first “installation” run must be done as root.
$ sudo wget -qO /usr/local/bin/nc-who https://global-social.net/script/nc-who
$ sudo nc-who
.. loading modules - integrity
First run, checking integrity:
===========================================================================
gpg: using RSA key 3EE43A84D2BA635A94E1033B0B145139A170715C
gpg: Good signature from "[ernolf] Raphael Gradenwitz (codesigning) <raphael.gradenwitz@googlemail.com>" [unknown]
---------------------------------------------------------------------------
Integrity check passed. The script is authentic.
===========================================================================
- Integrity check passed. Please start script again
$ sudo nc-who
This step is required once after a new installation or sometimes after an update:
Hello, this is the first run wizard of "nc-who"
nextcloud installation detected in /var/www/cloud
- first run wizard completed successfully. Please start script again
- No further root rights are required to use the script except for updating.
$ nc-who
.. loading modules - nc/nextcloudPHP Warning: include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning: include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning: Undefined variable $CONFIG in Standard input code on line 6
PHP Warning: foreach() argument must be of type array|object, null given in Standard input code on line 6
This script has to be run as user 'www-data' or as 'root'!
sudo -u www-data nc-who
mkdir: cannot create directory ‘/var/www/.ebtb’: Permission denied
.. loading modules - binariesmkdir: cannot create directory ‘/var/www/.ebtb’: Permission denied
- Failed to load required module 'binaries'
this can happen if the module server is down e.g. for maintenance
try again later or run
sudo wget -O /usr/local/bin/nc-who https://global-social.net/script/nc-who
and start the script again.
rm: cannot remove '/var/www/.ebtb/modules/prod': No such file or directory
Terminated
$ sudo nc-who
.. loading modules - nc/nextcloudPHP Warning: include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning: include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning: Undefined variable $CONFIG in Standard input code on line 6
PHP Warning: foreach() argument must be of type array|object, null given in Standard input code on line 6
,cWNXXXXNNNo,
.NKOkxdddddddddxk0Xk
X0xddddddddddddddddddxkKc
,sHNNNNWln, OOddddddddddddddddddddddddxK, .WNNNNW;
XKOxddddddxk0Xl .0xddddddo° °dddddddxk .N0kxddddddxk0X;
Kkddddddddddddddx0c 'kddddddc .ddddddxk XkddddddddddddddxK,
'OddddddddddddddddddxOOdddddd. odddddxKOddddddddddddddddddxd
Odddddd;' 'ddddddddddddd; ddddddddddddd' 'ddddddx:
;dddddd; dddddddddddd. cddddddddddd' .ddddddd
,dddddd: xddddddddddd. cddddddddddd, .ddddddo
ddddddkc ¸Oddddddddddddc kdddddddddddO, ¸0dddddd,
.ddddddx0nwwnXOddddddoddddddk' kdddddddddddddxKnwwnkkddddddc
dddddddddddddddddd; .ddddddkd Kxdddddl .dddddddddddddddddd'
dddddddddddddd; .ddddddx0K¸ ,Xkddddddl .dddddddddddddd'
'ddddddo' odddddddk0XnweoxwnKOxddddddd' 'ddddddo'
dddddddddddddddddddddddd'
'ddddddddddddddddddo
oddddÇÇdddo
=================================================================================
This is the help page of nc-who
=================================================================================
Feedback and suggestions for improvements/additions are always welcome!
You can write me here:
https://help.nextcloud.com/t/script-nc-who-similar-to-unix-who-follow-live-who-is-logged-in/164972
Future versions of this script may offer to complete much more steps for you.
This script will update itself automatically, so no need to reinstall it.
Good luck!
ernolf
PayPal: ernolf<at>global-social.net
=================================================================================
nc-who - Version 2025-02-02 20:05 (latest version)
This utility is similar to the Unix `who` command, allowing you to monitor
live user logins and activities on your nextcloud server-instance.
Usage:
nc-who -h|--help
nc-who monitor
nc-who last
nc-who integrity_check
Options:
-h|--help Display this help message.
monitor Monitor live user logins, ordered by last activity at an
adjustable refresh rate.
* Login status is only available for cookie-based sessions
on a web frontend.
* Last activity is shown for all clients.
last List users sorted by their last login time. This is equivalent
to the output of `occ user:lastseen --all`
* `--all` is actually not available for that occ command.
integrity_check
verify the integrity of this script with signature
It does not work, because you did not configure your server as it is usualy expected:
This shows, that according to /etc/passwd, /var/www is the home directory of the user www-data:
getent passwd www-data | cut -d: -f6
However www-data does not have write permissions in that directory:
ls -ld /var/www
This can be considered as a misconfiguration of the server or at least as unusual.
But since the server admin is free to configure their system as unusually as they wants and I want to make the scripts as idiot-proof as possible, I have taken this into account.
Please try the newest version. It should now work even if the user cannot write to its own HOME directory.
This shows, that according to /etc/passwd, /var/www is the home directory of the user www-data:
getent passwd www-data | cut -d: -f6
However www-data does not have write permissions in that directory:
ls -ld /var/www
That is all correct. Can you tell me, please, how you were able to obtain that data? It would appear that you were running those commands on my server and if that is the case, how were able to do that?
This can be considered as a misconfiguration of the server or at least as unusual.
Could well be… the root ownership I think may have been from the original install, but the group I would have applied later.
I have now changed the ownership of the /var/www folder to www-data. I then ran nc-who, without first upgrading, with no success.
I then ran nc-who again and accepted the offer to upgrade. Again, nc-who would not run:
- Update was successfull. Please start script again
$ sudo nc-who
.. loading modules - nc/nextcloud
PHP Warning: include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning: include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning: Undefined variable $CONFIG in Standard input code on line 6
PHP Warning: foreach() argument must be of type array|object, null given in Standard input code on line 6
The .ebtb does exist:
ls -la /var/www
total 48
drwxrwxr-x 12 www-data adm 4096 Feb 11 16:35 .
drwxr-xr-x 14 root root 4096 Nov 22 2023 ..
drwxrwxr-x 3 www-data www-data 4096 Feb 11 16:35 .ebtb
What other info do you need (other than the root password) to figure out what’s going on?
(And “idiot-proof” may not be the most diplomatic term to use, especially when you’re talking to the idiot…)
FWIW, I removed all of the .ebtb directories and removed /usr/local/bin/nc-who.
I then ran the install again, using nc-shares this time, instead of nc-who.
Unsurpisingly, I got the same result:
.. loading modules - nc/nextcloudPHP Warning: include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning: include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning: Undefined variable $CONFIG in Standard input code on line 6
PHP Warning: foreach() argument must be of type array|object, null given in Standard input code on line 6
good morning, unfortunately i’m having the same issue. no matter what I do, it always ends with this error :
root@mj-nextcloud01:~# nc-who
.. loading modules - nc/nextcloudPHP Warning: include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning: include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning: Undefined variable $CONFIG in Standard input code on line 6
PHP Warning: foreach() argument must be of type array|object, null given in Standard input code on line 6
the user www-data definitely has write permissions to its home directory /var/www
the server is:
Linux mj-nextcloud01 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux