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