checkroot
v1.0.0
Published
Find if the current user is root or not
Downloads
6
Maintainers
Readme
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