% su - [enter root password]
% su bob[robg adds: Further proof that root really can do everything ... and why you should be quite careful with it. Any comments from the UNIX experts?]
|
|
|
In order to execute a command via another user, without knowing their password, you can use the "su" command to log into root and then their account.
[robg adds: Further proof that root really can do everything ... and why you should be quite careful with it. Any comments from the UNIX experts?]
•
[21,484 views]
Hint Options
Execute commands as another user
You should really use sudo for this. Just type:
Not only is it easier, but it's also very customizable -- you can control which users can execute which programs as what users. -Esme
Execute commands as another user
You can also use the following to become the root user (if you have sudo access and authorization to execute the command): This next command is helpful if you want to run a series of commands as another user (after you are root, naturally): This method is much safer than logging in as root; you don't even have to enalbe the root password. I've been using UNIX for years, and I haven't enabled the root password on any of my Macs without loosing any flexibility.
Execute commands as another user
su bob will work just fine if all you want to do is change to another identity; you don't need to su to root first if you know that id's password. At the password prompt, just type "bob's" password.
Execute commands as another user
This of course only works if you an administrator. You can't su to root or any other user if you are not an admin on the box.
Execute commands as another user
Only users in group "wheel'' (normally gid 0) or group "admin'' (normally gid 20) can su to "root''.
False
The su command will work as ANY user, regardless of privilege. If I am logged in as "sam" and wish to execute commands as "joe", I type:
Execute commands as another user
su stands for "substitute user identity".
Use "sudo -u [username] [command]"
sudo -u [username] [command]
Haha.
I guess this was covered in the first reply. That'll teach me for starting a post, forgetting about it, and then submitting it a couple of hours later.
Execute commands as another user
Note, it is often preferred to execute the command this way: su - username The presence of the hyphen means "use the new user's environment"... otherwise the su command will not overwrite the old user's environment variables.
Why do people insist on having root enabled??
Yet another hint that requires root to be enabled when, as has been pointed out by many others, sudo is what you want to be using!
Quit yer Whining
You know, preaching to people on why not to use root is really pointless. If they want to use root, they will. It's really none of your concern.
Quit yer Whining
You don't like using root? Fine. Don't. Screaming about it
whenever someone else mentions using it doesn't help.
Actually, it helped a lot; I didn't really think about some of the points he brought up. Inasmuch as this is a HINTS website, you know, a place where some of us come to learn things that we previously didn't know or hadn't figured out on our own about OS X (including the CLI/ UNIX'ish underpinnings of it, I think that the original poster's comments were infact very helpful. Yours, on the otherhand, was pure flamebait.
Quit yer Whining
Not to mention the fact that sudo as a command can't properly be tailored to a particular system unless someone on the system has access to /etc/sudoers for editing -- ie, is root.
Quit yer Whining
Mac OS X is configured so that all administrators are placed in the admin (80) group, and the admin group is given sudo privileges in /etc/sudoers. Therefore, administrators can edit /etc/sudoers by "sudo visudo", and can create more groups and assign individual non-admin users or groups whatever sudo privileges they merit (none, by default). If an administrator removes the admin group's permission to edit the config file, root has to be enabled, but that's why you only give admin access to people you trust!
What about GUI commands?
I discovered this trick some time ago, but didn't find it useful because I
What about GUI commands?
"open" will open the command on whatever users display it is executed under. if they arent logged in, they dont have a display. you can ssh in as the logged in user, and run open, and it will work.
What about GUI commands?
This is similar to the way displays are handled on Xwindows with xhost set to -, only I don't think there's any way to allow all hosts to connect to OSX's display (I haven't seen one yet, at least). The purpose of xhosts on Xwindows systems is to allow other hosts to connect to and bring up windows on your display.
What about GUI commands?
The short answer is, no. Under Mac OS X, you can't launch an application as another user (other than root).
Execute commands as another user
Pardon my ignorance as I am very new to all this, but is there a way to change a user like this, and then perform tasks as that user in the Finder? (without loggin out) Or does this switch mentioned in this hint only apply for the Terminal session and to commands entered within the Terminal?
Execute commands as another user
Nope: you'll be root in the terminal if you execute a command such as
Execute commands as another user
I've used sudo and su a lot, and there are reasons for using one or the other.
Execute GUI commands as another user
You can actually use GUI programs as root without logging out—it just involves restarting the program you want to use as root. So, on the rare occasion I need to use the Finder as root, I |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.29 seconds |
|