≡ Menu

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...
{ 0 comments… add one }

Leave a Comment