You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
dotfiles/.aliases.d/chmod_cheats.sh

56 lines
1.3 KiB

#cheat-sheet
chmod-cheat() {
echo "chmod =:"
echo "1 = execute only"
echo "2 = write only"
echo "3 = write and execute (1+2)"
echo "4 = read only"
echo "5 = read and execute (4+1)"
echo "6 = read and write (4+2)"
echo "7 = read and write and execute (4+2+1)"
echo "qmod =:"
echo "web) 0644"
echo "safe) 0640"
echo "sbin) 0550"
echo "bin) 0555"
echo "exe) 0555"
echo "+w) 0660"
echo "write) 0664"
echo "readonly) 0440"
echo "+775) 775"
echo -e "\nqmod (MODE) /path/file\n"
}
qmod() {
if [ -e "$2" ]; then
if [ -n "$1" ]; then
if [ -d "$2" ] && [ "$3" == "-R" ]
then
OPTION="-R"
else
OPTION=""
fi
case $1 in
web) /bin/chmod $OPTION 0644 "$2" ;;
safe) /bin/chmod $OPTION 0640 "$2" ;;
sbin) /bin/chmod $OPTION 0550 "$2" ;;
bin) /bin/chmod $OPTION 0555 "$2" ;;
exe) /bin/chmod $OPTION 0555 "$2" ;;
+w) /bin/chmod $OPTION 0660 "$2" ;;
write) /bin/chmod $OPTION 0664 "$2" ;;
readonly) /bin/chmod $OPTION 0440 "$2" ;;
+775) /bin/chmod $OPTION 775 "$2" ;;
775) echo "are you sure? If so, do chmod +775 file" ;;
*) /bin/chmod $OPTION $1 "$2" ;;
esac
if [ $? -eq 0 ]; then
echo "$1 chmod complete on $2"
else
echo "$1 chmod on $2 FAILED!!!"
fi
else
chmod-cheat
fi
else
chmod-cheat
fi
}