Jump to content
2 posts in this topic

Recommended Posts

I wrote this shell script for myself quickly as I've been moving kexts in and out trying to find the perfect balance. I cleaned it up a bit and figured I'd post it here to help save some keystrokes and some time of those doing that same as I was. You could run diskutility every time, but lets face it, this is quicker for a small batch of files.

 

Basically it RECURSIVELY sets the ownership to root:wheel and permissions to 755 of any file/dir you type as an argument. I personally have named it chode because in my sick mind, that is a combination of chmod and chown. Feel free to mod this however you'd like to suit your needs. It does minimal prerequisite checking: just root and that an argument has been entered. It doesn't check to ensure the file you specified exists or ask you if you're sure so be careful.

 

For those new to shell scripts, I've included a zip below. Place chode.zip on your desktop an unzip it. Then, open terminal and type:

mv ~/Desktop/chode /usr/bin/
sudo chown root:wheel /usr/bin/chode
sudo chmod 755 /usr/bin/chode

 

Usage: chode file1 file2 file3 etc

 

#!/bin/sh
#A quick scribble by SynMoo to simplify specific permissions repair.
#Doesn't verify file's existance! Too lazy!
#Check for arguments
if [ "$*" == "" ]; then
echo "Usage: chode target1 ... targetN"
exit 127
fi
#Check for root
if [ "$USER" != "root" ]; then
echo "chode: You're not root! Did you sudo?"
exit 127
fi
#Get busy
echo "Setting owner root:wheel recursive..."
chown -R root:wheel $*
echo "Setting permissions 755 recursive..."
chmod -R 755 $*
#Visual verification for the paranoid
echo ""
echo "Verify below:"
ls -l $*
echo ""
echo "Done"

 

Enjoy!

chode_fixed.zip

Edited by SynMoo
×
×
  • Create New...