I need help with creating either an if statement that will look at the $PATH for root and remove any world writable permissions.
Unix OSScripting LanguagesShell Scripting
Last Comment
atom_jelly
8/22/2022 - Mon
woolmilkporc
for dir in $(echo $PATH | tr ":" " "); do echo chmod -R o-w $dir; done
Or, shorter:
echo chmod -R o-w $(echo $PATH | tr ":" " ")
echo is for a dry run, remove it to actually perform the operations.
Run the above as root.
atom_jelly
ASKER
This works! Thanks just one more question I believe the STIG finding is for any world writable permissions for root's $PATH. So could I put in there chmod -R u+w $dir
Or, shorter:
echo chmod -R o-w $(echo $PATH | tr ":" " ")
echo is for a dry run, remove it to actually perform the operations.
Run the above as root.