I have a script that needs to run as root. It also has a configuration file which is read using source:source conf.shI would like to check that normal user can't edit conf.sh and therefore get root access.I can check who's the file owner and what permissions group and others have:if [[ $(stat -c %a conf.sh | egrep .2.|.3.|.6.|.7.|..2|..3|..6|..7) !=  ]] || [[ $(stat -c %u conf.sh) != 0 ]]; then    #don't execute the filefiAm I missing anything here? Are there any best practices? 
Check that only root can edit a script before executing it
bash;shell script;security;root
I'd do it with arithmetic evaluation:if [[ $(stat -c '%u' conf.sh) -ne 0 -o \      $(( $(stat -c '%a' conf.sh) & 0044)) -ne 0 ]]; then    # file's owner is not root or file is writable by group or worldfi