Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a command to check if Git Bash is opened in Administrator mode?

Let's say you opened a Git Bash console and used it for a time but you forgot if you opened it as Administrator or not.

Is there a way to check this in the current console, without closing and opening it again?

like image 657
Samurai Jack Avatar asked Apr 27 '17 06:04

Samurai Jack


1 Answers

Adapted from the thread on how to check for admin rights, run the following:

if [[ $(sfc 2>&1 | tr -d '\0') =~ SCANNOW ]]; then echo Administrator; else echo $USERNAME; fi

If you are running git-bash as Administrator, it will print Administrator, otherwise it will print your username.

like image 67
daveloyall Avatar answered Oct 04 '22 15:10

daveloyall