Posted By

vikiyou on 03/22/11


Tagged

Bash linux root


Versions (?)

Check root user on Linux


 / Published in: Bash
 

Check if the user run this script is root.

  1. # return 1, is not root
  2. # return 0, is root
  3. if_root()
  4. {
  5. run_user=`id -u`
  6. [ $run_user -eq 0 ] || return 1
  7. return 0
  8. }

Report this snippet  

You need to login to post a comment.