SyntaxFix
Write A Post
Hire A Developer
Questions
The above answers won't let you quote inside the quotes. This solution will:
sudo -su nobody umask 0000 \; mkdir -p "$targetdir"
Both the umask command and the mkdir-command runs in with the 'nobody' user.