This script allows WHM/cpanel server admin to copy an file to all cpanel accounts certian folder. In this case we copying /root/.htaccess into all wp-content folders acros all cpanel accounts.

The script can be modiffied to delete file or add any other file to all cpanel accounts to folder with certain name (example: wp-content).
The script can be also used to find some phrasse on all cpanel accounts or do any other acction with some/all cpanel account files.

If you need me to tweak the script somehow, let me know please (paid service)

Script commands explanation

1) First we search wp-content folders in one cpanel user public_html folder structure
2) we chown .htaccess to match that cpanel user
3) the results of find command (path to wp-content) are added into file
4) for each path we copy .htaccess to that path

The script

echo "Script for doing an command on all cpanel account files"

for i in $(ls -A1 /var/cpanel/users/ | grep -v system); do
# find phrasse in all users files
# grep -Ril "cracker" /home/$i/public_html
# change user access rights to some folder or file
# chown $i:nobody /home/$i/public_html;
# copy some file to/from certain directory in all accounts (-p is to preserve permissions)
## for s in $(ls -A1 /home/usernamehere/public_html/_sub/); do
#cp -rp follow-nofollow-control /home/usernamehere/public_html/_sub/$s/wp-content/plugins/
## done
# find file which name contains phrasse
# find /home/$i/public_html -type f -iname "*.sh" -print

chown $i:$i /root/.htaccess
ls -lha /root | grep .hta
#find /home/$i/public_html -type d -name "wp-content" -o -name "cache" > wpcontent
> wpcontent
find /home/$i/public_html -type d -name "wp-content" >> wpcontent
for pathh in $(cat wpcontent);do
cp -p /root/.htaccess $pathh