How to check from command line if your user has admin rights

This post explains how to check if your user has admin rights using your command line.

Linux

Using sudo command

You can run a command like this:
timeout 2 sudo id && echo Access granted || echo Access denied

Mac OS X

Using sudo command

You can use the same timeout command on Mac, but you need to install coreutils.

To install coreutils using brew:
brew install coreutils

You might be also interested in…

External References

Leave a Reply

Your email address will not be published. Required fields are marked *