I want to run a script with sudo privileges when a new user is added to my system. More specifically, whenever I create a new user (with useradd or adduser), I want to be able to create a folder outside the user's home directory, under a directory owned by root (this would a shared HDD). is there a way to do this systematically so I don't have to manually create a folder for each user I add to my system? I know I can customize the user's home enviroment my changing the files/directories in /etc/skel but I want to be able to assign a shared folder to the new user elsewhere, and named it "${USER}_data"
I tried adding a simple mkdir path_to_rootDir/${USER}_data command in different system-wide initialization files (/etc/.profile, /etc/.bashrc), but it always fails to create the directory because it is not run as root (permission denied).