Linux: Resetting External Drive Permisions to Root for access issues ( ie: USB HDD )

USB devices will need to be treated as if ONLY the root user will access.. BECAUSE....

... if non-root user owns the files... NO ONE ELSE CAN ADMIN them

here's a bash script to both reclaim ownership, then reset permisions to 777

this script accepts 1 argument, or it will process



function pausing {
    read -p "Press ENTER to CONTINUE, CTRL-C to ABORT" paused
    line
}
function line {
    echo "---------------------------------------------------"
}
line
echo "update usb hdd file/folder permissions recursively"
echo "target: $1"
line
ls -la "$1"

echo "running chown -R root:root"
line
sudo chown -R root:root "$1"
echo "done.."

echo "running chmod -R 777"
line
sudo chmod -R 777 "$1"
echo "done.."

echo "done, listing target...."
ls -la "$1"
pausing

 

Tags