-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathowned
34 lines (33 loc) · 1.94 KB
/
owned
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /bin/bash
function owned()
{
if [ -f $1 ]
then
select ownchoice in "Own the file" "Change File Access Permissions"
do
case "$ownchoice" in
"Own the file")
echo -e "Target= $1\nIf this is not correct, end this process now. No changes will be made."
pressanykey
sudo chown -R -H $iamme:$iamme $(echo -e $1)
return
;;
"Change File Access Permissions")
echo -e "$(color 8)-------------------------------------------------------------------------------------------------$(reset)"
echo -e "$(color 8)|$(reset) Owner $(color 8)|$(reset) Group $(color 8)|$(reset) Others $(color 8)|$(reset)"
echo -e "$(color 8)|$(reset)$(color 1)(R)$(reset)ead, $(color 2)(W)$(reset)rite, $(color 3)(E)$(reset)xecute $(color 8)|$(reset)$(color 1)(R)$(reset)ead, $(color 2)(W)$(reset)rite, $(color 3)(E)$(reset)xecute $(color 8)|$(reset)$(color 1)(R)$(reset)ead, $(color 2)(W)$(reset)rite, $(color 3)(E)$(reset)xecute $(color 8)|$(reset)"
echo -e "$(color 8)-------------------------------------------------------------------------------------------------"
echo
echo -e "$(color 1)0$(color 2)0$(color 3)0$(reset) = 0 (Completely locked)\n$(color 1)0$(color 2)0$(color 3)1$(reset) = 1 (Execute only)\n$(color 1)0$(color 2)1$(color 3)0$(reset) = 2 (Write only) \n$(color 1)0$(color 2)1$(color 3)1$(reset) = 3 (Write and execute)\n$(color 1)1$(color 2)0$(color 3)0$(reset) = 4 (Read only)\n$(color 1)1$(color 2)0$(color 3)1$(reset) = 5 (Read and execute)\n$(color 1)1$(color 2)1$(color 3)0$(reset) = 6 (Read and write)\n$(color 1)1$(color 2)1$(color 3)1$(reset) = 7 (Full access)"
echo -e "Enter permissions number desired."
read permnum
pressanykey
sudo chmod -R $permnum $(echo -e $1)
return
;;
esac
done
else
echo -e "Please input valid file name after command, like this: owned <filename>"
fi
}