This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/own.sh

23 lines
437 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}"
}