sudo
oferece a opção -u
para isso, consulte man sudo
:
-u user, --user=user
Run the command as a user other than the default target user (usually root).
The user may be either a user name or a numeric user ID(UID) prefixed
with the ‘#’ character (e.g. #0 for UID 0). When running commands as a UID,
many shells require that the ‘#’ beescaped with a backslash (‘\’).
Some security policies may restrict UIDs to those listed in the password
database. The sudoers policyallows UIDs that are not in the password database
as long as the targetpw option is not set. Other security policies may
not support this.
Para o seu exemplo, isso seria:
sudo -u USERNAME mkdir /home/USERNAME/mystuff