Jump to content


Force application to run as Administrator?

  • Please log in to reply
4 replies to this topic

#1 macfan777


    Uber Mac Geek

  • Members
  • 288 posts

Posted 01 April 2008 - 10:23 PM

You know when some applications ask you to type in your administrator password, and will let you run as another user without logging into that account? I need to run some Terminal commands using sudo, but it will only let me do it if I am already logged in as an administrator. Is there a way to run the Terminal, or any other application for that matter, as an administrator while in a non-administrator account? Or, if not, is there a Terminal command that will let me act under another account?

#2 Graham


    Mac Geek God

  • Members
  • 3,071 posts
  • Twitter:grahamgilbert
  • Gender:Male
  • Location:London, UK

Posted 01 April 2008 - 10:37 PM

There's a solution at http://forums.macosx...hp/t-45703.html

But it kinda defeats the point of running as a standard user since the terminal isn't just an app, it's your window to the core of OSX. You might as well just run as an administrator really...

#3 ithonicfury


    Alpha Mac Geek

  • Members
  • 786 posts

Posted 01 April 2008 - 10:39 PM

Log in as an admin.
Launch Terminal, and run "sudo visudo"
Scroll down to the end and put in "username ALL=(ALL) ALL" (no quotes, and replace username with your username)
Type in ":wq" (no quotes)

Log into the other account and try to run something with sudo.

#4 macfan777


    Uber Mac Geek

  • Members
  • 288 posts

Posted 01 April 2008 - 11:34 PM

Awesome, I found the command in the macosxhints thread. Here it is:
su - AdminAccountName
It then prompts you for the password to that account and lets you run commands using that account's privileges.

The only reason I didn't want to edit the sudoers file is that I don't want the standard account to be able to run sudo without the admin password - sudo using the standard account's password is kind of pointless.

Edited by macfan777, 01 April 2008 - 11:35 PM.

#5 ganbustein


    Super Mac Geek

  • Members
  • 100 posts
  • Location:Berkeley CA

Posted 02 April 2008 - 04:05 AM

Yeah, I do that (su -l user) all the time. It's a LOT faster than Fast User Switching, and lets me open a Terminal window as each of two (or even three) users. I can do something as admin in one of them, and immediately see what affect it has on a non-admin user. Switching between users becomes as easy as clicking on a different window. Notice that doing this to drop privilege can be just as useful as doing it to gain privilege.

Fast User Switching comes with beautiful eye candy, but it gets real old real fast, especially since it won't let you put both users on the same screen at the same time.

A similarly useful feature is using ssh between machines. I have one machine running Leopard, and one running Tiger. The Tiger machine has the comfortable chair, so I spend a lot of time there, but if I need to investigate one of the differences between the OSes, ssh is not only quicker and easier than walking over there, it also lets me see the results side by side in windows on the same screen. I can even copy/paste between them.

One tip: if you do it a lot, it's real easy to lose track of who's logged in on each window. I put the following in my .bashrc file:


PS1='\u@\h:\W($?)\$ '
This snippet sets your prompt to user@host:folder(status)$ , (complete with the bolding), so I see at a glance which user on which machine is using that window, the last component of the current working directory, and the result status of the last command. Making the prompt bold makes it easier to find prior commands, especially after one of them has spewed out a bunch of output.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users