checkroot

Find if the current user is root or not


Keywords
root, sudo, username, user, name, login, logname, lname, whoami, id, env, environment, var, variable
License
MIT
Install
npm install checkroot@1.0.0

Documentation

checkroot

Check if the current user is root or not

Install

$ npm install --save checkroot

Usage

const checkroot = require('checkroot');

// returns
//   true, if the current user is root
//   false, otherwise
console.log(checkroot());

API

First it tries to get the username from the USER and LOGNAME environment variables. In the rare case when none of these environment variables are set, it falls back to $ id -un on Linux / MacOS and $ whoami on Windows. The result is cached using mem.

checkroot()

Returns true, if the current user is root and false, otherwise.

License

MIT © Sahil Dua