Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any graphical "sudo" for Mac OS X?

Tags:

I'm designing a little software in Java. I don't know the term/definition to what I'm doing, but I'm prompting commands from Java to the terminal. Something like this:

Process process = Runtime.getRuntime().exec("command"); 

I've done this before in Linux, and I used gksudo for commands that required the root password.

Is there any gksudo in OS X? Any graphical popup asking for root password?

like image 657
Johannes Avatar asked Oct 04 '09 19:10

Johannes


People also ask

Does sudo exist on Mac?

By default, Mac OS X includes the admin group in the sudoers file and gives that group authorization to run any command with sudo . Mac OS X accounts given administrator privileges become members of the admin group, and thereby receive complete sudo privileges.

Is macOS command line or GUI?

The Mac Terminal is a command line interface (CLI) for the macOS operating system (OS). Mac Terminal is typically used by network administrators and advanced technical users who want to initiate an action that is not supported by the operating system's graphical user interface (GUI).


2 Answers

You can more ore less manage to write your own with an AppleScript shell script:

#!/bin/sh osascript -e "do shell script \"$*\" with administrator privileges" 

cocoasudo looks aesthetically more pleasing, but this is already deployed.

like image 162
ZJR Avatar answered Sep 28 '22 18:09

ZJR


This also looks promising: cocoasudo

enter image description here

It uses the OSX native Authorization Services API:

For Mac OS X Cocoa-based apps, there is analagous ability to sudo provided via the Authorization Services API. Use of the API allows you to prompt the user for their username and password requesting the ability to escalate privileges.

For that case, I’ve written a small utility that I’ve dubbed cocoasudo. Use cocoasudo in much the same way you’d use sudo. However, instead of users being prompted for their password in a Terminal window, they’ll get a dialog prompt via the Authorization Services API.

like image 20
tam7t Avatar answered Sep 28 '22 16:09

tam7t