Check root user on Linux


/ Published in: Bash
Save to your folder(s)

Check if the user run this script is root.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.