cprima It would be great to know which steps you did for the upgrade.
If you did the things from Nicolas' upgrade guide https://moodlebox.net/en/help/moodle-version-update/ then everything should work fine
sudo -u www-data -g moodlebox git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
sudo -u www-data -g moodlebox git fetch origin
sudo -u www-data -g moodlebox git checkout MOODLE_401_STABLE
After these terminal commands Nicolas writes to open http://moodlebox.home/admin/ in your browser to start the upgrade in the browser. In this case the installation runs with the server rights of the user
www-data and everything is okay.
If you complete the installation in the terminal you need to use also the user
sudo -u www-data -g moodlebox php /var/www/moodle/admin/cli/upgrade.php
If you run the Moodle script upgrade.php with the rights of the user
root you will get the folder /var/cache/moodle/application with an exclusive
root access. Please read the https://docs.moodle.org/401/en/Administration_via_command_line#Running_CLI_scripts for this fact.