Linux / UNIX Bash: Copy Set of Files to All Users Home Directory

If you would like to copy a set of files for all existing users, use the following scripting trick. It will save lots of manual work. First you need to grab all user names from /etc/passwd file using the cut command:# cut -d: -f1 /etc/passwd However, the above will grab all system account too. To grab only user account (UID >= 500), enter:# awk -F':' '{ if ( $3 >= 500 ) print $1 }' /etc/passwd Next, you can use the shell for loop command to copy file(s) and set the correct permissions on the file. The id command can be used to obtain the correct user ID and group ID for each user.