Jump to content
Sign in to follow this  
macfan777

Force application to run as Administrator?

Recommended Posts

macfan777    0

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?

Share this post


Link to post
Share on other sites
ithonicfury    0

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)

Hit ESC

Type in ":wq" (no quotes)

 

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

Share this post


Link to post
Share on other sites
macfan777    0

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

Share this post


Link to post
Share on other sites
ganbustein    0

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:

 

ESC=$'\e'
VT_BOLD="${ESC}[1m"
VT_NORMAL="${ESC}[0m"
VT_UL="${ESC}[4m"
export ESC VT_BOLD VT_NORMAL VT_UL

PS1='\u@\h:\W($?)\$ '
PS1="\[$VT_BOLD\]$PS1\[$VT_NORMAL\]"

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing

    No registered users viewing this page.

  • Who's Online (See full list)

    There are no registered users currently online

×