The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can't login root account due to can't find root shell neikel AIX 2 01-30-2008 08:07 PM
how to access root priveliges if root password is lost wojtyla Linux 1 02-18-2005 03:24 AM
Run non-root script as root with non-root environment bubba112557 UNIX for Dummies Questions & Answers 2 12-02-2004 09:39 PM
Lost root password / Can't login as root Perderabo Answers to Frequently Asked Questions 0 06-22-2004 04:40 PM
fsstat: root file system needs checking mbco UNIX for Dummies Questions & Answers 0 04-26-2004 01:58 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-07-2008
Paris Heng's Avatar
Registered User
 

Join Date: Jan 2008
Location: Kuala Lumpur, MY
Posts: 4
Checking ~ Root

Dear,

How actually we can using a sh script to check weather we are in root or user?
Reply With Quote
Forum Sponsor
  #2  
Old 03-07-2008
sad_angle's Avatar
Registered User
 

Join Date: Jun 2001
Location: Madison, WI
Posts: 73
try the command
#whoami
Reply With Quote
  #3  
Old 03-10-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
if ! id | grep -q "uid=0(root)" ; then
print "ERROR: must be root in order to run this script
fi
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:02 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0