Back to the main page

The script for checking if user is root


#!/bin/sh	
#	
# Check if user is root	
#	
#set -x 	

if [ `id | cut -d= -f3 | cut -d\( -f1` = 0 ]	
 then	
        echo	
        echo " Okay, you are root and can run this script"	
        echo	
 else	
        korisnik=`id | cut -d= -f2 | cut -d\( -f2 |cut -d\) -f1`	
        echo	
        echo  "Sorry, you are NOT root. you are $korisnik and cannot run this script"	
        echo	
fi	
exit 0	
Back to the main page