24 lines
454 B
Bash
24 lines
454 B
Bash
# change file ownership to specified user id and restrict access to him.
|
|
# usage: own [USER] [FILES]
|
|
own()
|
|
{
|
|
local file="${2}"
|
|
local user="${1}"
|
|
|
|
# default to current dir.
|
|
if [ "${file}" = "" ]; then
|
|
file='.'
|
|
fi
|
|
|
|
# default to current user.
|
|
if [ "${user}" = "" ]; then
|
|
user="${UID}"
|
|
fi
|
|
|
|
# set ownership.
|
|
chown "${user}":"${user}" -R "${file}" &> /dev/null
|
|
|
|
# remove access from group and others.
|
|
chmod -077 -R "${file}"
|
|
}
|