I wrote a script that helps clean up my downloads and anime, but it won't run without root.
So I tried adding it to /etc/sudoers (edited using techraf's suggestions):
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
Cmnd_Alias FILEPERM_CMDS = /bin/chown, /bin/chmod
# User privilege specification
root ALL=(ALL:ALL) ALL
myUsernane ALL = NOPASSWD: /media/96e60511-62ca-48ba-bccc-9b365bfcc4e5/Programs/down.sh
myUsernane ALL = NOPASSWD: /media/96e60511-62ca-48ba-bccc-9b365bfcc4e5/Programs/rehamer.sh
myUsernane ALL=(ALL) NOPASSWD: /bin/chown
myUsernane ALL=(ALL) NOPASSWD: /bin/chmod
myUsernane ALL=(ALL) NOPASSWD: FILEPERM_CMDS
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
But this doesn't work...
Here's what's inside the script:
sudo chown -cR myUsername:users $downloads $anime >>"$default"logs/own.log 2>&1
echo owned
sudo chmod -cR 664 $anime >>"$default"logs/mod.log 2>&1
sudo chmod -cR 765 $downloads >>"$default"logs/mod.log 2>&1
sudo find $downloads $anime -type d -exec chmod a+x {} \; >>"$default"logs/mod.log 2>&1
echo moded
rm -vrf $downloads*.ignore >>"$default"logs/rm.log 2>&1
echo removed ignored files
If I leave sudo in the script it asks for my password once and does work. If I remove sudo from my script it runs without password promoting, but I still get the Permissions denied
errors over and over. How can u fix this?