# Change file ownership to specified user id and restrict access to him. # Root user by default. This directory recursively by default. # Usage: own [USER] [FILES] function own() { local IFS=$'\n' local files=("${@:2}") local user="${1}" # default to current dir. if [ "${files[*]}" = "" ]; then files=(".") fi # default to current user. if [ "${user}" = "" ]; then user="${UID}" fi for file in "${files[@]}"; do # set ownership. chown "${user}":"${user}" -R "${file}" &> /dev/null # remove access from group and others. chmod -077 -R "${file}" done }