CLI in apps: files and directory created got root ownership
-
In apps (at least WP-D) when you create a directory or file in the app-Terminal it gets 'root' as owner. Is this intended?
I noticed that after restart of the app it has www-data. -
The terminal for most apps (if not all) default to login as "root" so this is by design. Restarting fixes the perms cause the startup script switches them to whatever the app needs (in wordpress's case it's www-data" if you wanna make it like that from the get go:
Use either:
chown www-data:www-data <whatever dir>
Or:
su - www-data
then mkdir where ever you need it:mkdir <whatever dir>
-
The apps itself run with minimal permissions but the Web Terminal gives you "root" access (this is a limited root and not server root) so that you can creates files as any user since some apps use multiple users. It's also required in situations where you restore/import the app and those files have different permissions than the one app uses.
But tl;dr this is intended. Use su like @murgero said or you can use gosu <username> <cmd> as well
-
-