The superuser UID is always 0 (from Linux source).
Check by UID
Bash: isRoot=$(($UID == 0))
Node.js: var isRoot = process.getuid && process.getuid() === 0;
Ruby: isRoot = Process.uid.zero?
Python: isRoot = os.geteuid() == 0
Haskell: let isRoot = fmap (== 0) getRealUserID
Check by Write Access
Bash: [[ -w / ]] && isRoot=true || isRoot=false
Ruby: isRoot = File.writable_real?("/")
Python: isRoot = os.access('/', os.W_OK)
#linux#cli