下記の例では、シェルスクリプトを実行したユーザが root であるかどうかを調べています。
if [ "$USER" != "root" ]; then echo "Executed by root." exit -1 fi