Results 1 to 3 of 3

Thread: bash check if in superuser mode

  1. #1

    Default bash check if in superuser mode

    In bash script, how do I check for superuser mode? (check if admin)

    username=root?

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    27,217
    Blog Entries
    15

    Default Re: bash check if in superuser mode

    Hi
    whoami, $UID, $EUID, id -u lots

    Code:
    if [[ $EUID -ne 0 ]]; then
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3

    Default Re: bash check if in superuser mode

    Quote Originally Posted by malcolmlewis View Post
    Hi
    whoami, $UID, $EUID, id -u lots

    Code:
    if [[ $EUID -ne 0 ]]; then
    That's worked.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •