#cross-platform #user #solution #privileged #finding #running #unix #superuser #deciding

is_superuser

A cross-platform solution for finding out if the running user is a superuser

1 stable release

1.0.1 Sep 18, 2022

#7 in #privileged

Download history 16/week @ 2025-03-12 503/week @ 2025-03-19 485/week @ 2025-03-26 963/week @ 2025-04-02 966/week @ 2025-04-09 959/week @ 2025-04-16 977/week @ 2025-04-23 486/week @ 2025-04-30 968/week @ 2025-05-07 813/week @ 2025-05-14 2001/week @ 2025-05-28 4254/week @ 2025-06-04 26/week @ 2025-06-18 386/week @ 2025-06-25

4,667 downloads per month

MIT license

5KB
56 lines

is_superuser

A simple cross-platform solution for deciding if a given user is privileged. Works on Unix (Linux and MacOS) and Windows, please make an issue if it doesn't work for you!

Usage:

use is_superuser::is_superuser;
fn main() {
    if is_superuser() {
        println!("I am running with sudo/admin privileges!");
    } else {
        println!("I am a normal user!");
    }
}

Dependencies

~215KB