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

24 lines
509 B
Bash

# 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 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}"
}