Given User is root user or not

Given User is root user or not

Write a Shellscript to given user is root user or not

 

#!/bin/bash
#title                :
#description     :
#author             : Coding Academi
#date                : 17012023
#version           : 2.0
#usage             :
#Copy Rights   : Coding Academi
#Contact          : 99855 17744

echo “Please enter the user name”
read userName

if [ `id -u $userName` -eq 0 ] then
echo “Give user is root user”
else
echo “Given user is not root user”
fi

Post Tags :

Leave a Reply

X