Run as root only

To make sure that a script will be run by root only:


#!/bin/sh

if [ `id -u` != 0 ]; then
  echo "Permission denied, must be root"
  exit
fi

# Do the thing...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.