Script to Copy a File to All Users Home Directory

#!/bin/bash
_HOME=”/home”
_FILE=”FileName”

# Get List of users
_USERS=$(cut -d : -f1 /etc/passwd)

for u in $_USERS
do
/bin/cp $_FILE ${_HOME}/${u}
chown $(id -un $u):$(id -gn $u) /${_HOME}/${u}/${FILE}
done

Leave a Comment