using root to mkdir in another users home directory
With install
, you can create a directory with a specific owner, group, and mode:
install -d -o <user> -g <group> -m <mode> <path>
sudo -u [username] mkdir /home/[username]/public_html/[folder_name]
works fine.
From what I can see the permissions and ownership is the same if I were to log in as the same user and create the folder under public_html
.
You can also call su -c "mkdir /home/[username]/public_html/[folder_name]" [username]