Command line render (linux) doesn't make me owner of the rendered images

I use this command (on linux) to render and shut down when finished:

$ sudo bash -c "blender -b './file.blend' -a && shutdown -P +5"

But then I’m not the owner of the rendered images, is there a way to fix this?

sudo chown -R maeshanne:maeshanne /path/to/rendered/images

Also this is not Python…
Moved your thread to technical support.

1 Like

Don’t ever run Blender with sudo
Unless you’re making changes to the system and know exactly what you’re doing, nothing should be executed with sudo.

2 Likes

sudo parameter from manpage:

-u user, --user=user
Run the command as a user other than the default target user (usually root).

So if you use sudo and give no user it will run as root… and also will write files as root…

What you really want is using sudo to shutdown the computer after your blender task as normal user has finnished… :thinking: there are severals bad answers in the internet how to make you superuser BAD idea or poll on something using computer power… so let me think for a while…

So there is no simple way on one command line to do this… but… a script like this

attention there are dragons here

#!/bin/bash
# run this script as root..

SIMPLEUSER=simpleuser

# now this will run blender as normal user (and this and the next one will fail if not root)

sudo -u $SIMPLEUSER bash -c "blender -b '/home/${SIMPLEUSER}/file.blend'" 

# this again will be done as root
shutdown -P +5

should do it…

(with filechown’ed to root:root and chmod u+x to exceute by user ← which would be root)

i did NOT really tested this… but used
echo "This is done by root." > /home/${SIMPLEUSER}/testing.txt
instead of the real shutdown and if the testing.txt file has root root privileges… after execution…

You may improve there parameters of your blender call…

(Maybe also the bash -c is not needed…)

Oh… and by the way… i’m on linux since… eons… :wink:

2 Likes

It seems to work without the sudo, thanks for the tip!

More recently, depending on the distro (and session type), shutdown can be executed without needing to be root. I think it’s specifically non-remote sessions that have permissions, which would make sense as they’re likely the only user accounts logged in.

Fairly sure shutdown or systemctl poweroff should work without elevated privilege on most Ubuntu-likes and probably Fedora.

1 Like