What you should do instead is run it as an unprivileged user, and then use a module like sudo-prompt to call the app again with a Node script that contains all the logic that requires superuser privileges, but with the ELECTRONRUNASNODE variable set in the child environment. About the root user in Activity Monitor. Even though the root account is 'disabled' by default in OS X, you will still see many system processes running under this account when you open Activity. Open launches the application you're asking for via LaunchServices which will load it as if you double clicked on it. If you however run the application binary directly it'll work. So for example, as root (so from a script that's already running as root, or via sudo) run /Applications/TextEdit.app/Contents/MacOS/TextEdit and TextEdit will run as root. For example, if you were hoping to run the iPad version of YouTube natively on your new MacBook Air, you’re going to be disappointed, as Google has blocked the ability for all of its iOS apps to.
On every Linux system, the root account is a special user that has administrative rights. Logging in as root (or executingcommands with root privileges) is necessary for many tasks. If you need to perform tasks as the root user, make sure you fully understand the commands you are running, and what consequences they have. A single careless or malformed command, run as root, can make the entire operating system unusable. Do your research, and always double-check every command before pressing Enter.
Logging in as root
The root account is similar to any other account in that it has a username ('root') and a password. If you know root's password, you can use it to log into the root account from the command line.
There is a special command named su (for 'super user,' or 'switch user') that allows you to run commands as the root account temporarily. From the command line, type:
Enter the password once prompted for the password. If successful, you are switched to the root user and can run commands with full system privileges.
Be careful while logged in as root. It is easy to forget you're currently the root user, and you might inadvertently run a command thinking you are only a mere mortal. One way to remind yourself if you are root or not is to check your command prompt. Many systems end their command prompt with a dollar sign ('$') if you're logged in as a normal user and a pound sign ('#') if you're root.
Or, you can use the whoami command to determine the account you are using.
When finished with your administrative tasks, you can run the exit or logout command to return to your standard user account.
When logging in as root, it is often useful to use a single dash after the su command, like this:
This command simulates a complete root login. It executes all of the root user's shell initialization scripts and sets all environment variables as if the root logged in to a fresh shell session. Depending on what task you need to perform, and how root is configured, this form of the su command might be optimal for you.
Running commands as root without the root password
It is possible, and often preferable, to run commands as root without logging into the root account by using the sudo command, which stands for 'superuser do.' If you prefix a command with sudo, you are prompted for your password (not the root password), and your name is checked against a special file called sudoers. If your account is listed there, your command runs with root privileges.
Using sudo makes it difficult to forget that you're root since you're not logged in to the root account, and are never going to forget to log out. Also, typing sudo every time you run a potentially destructive command reminds you to be extra careful and double check yourself.
If you need to add a user to the sudoers list, use the visudo command that requires root privileges to run, and allow you to safely edit the sensitive sudoers file.
![]() Additional information
It is highly recommended that GUI interfaces not be run as root. That can easily lead to disaster. It is best to log in as a normal unprivileged user and to only use root's powers as required.
<<TableOfContents: execution failed [Argument 'maxdepth' must be an integer value, not '[1]'] (see also the log)>>
1. Using the su command
Many commands can only be run as the root user so to run these commands we need to become 'root'. To do this, we can use the su command (substitute user). The su command takes the following format:
or
but most commonly we will use su to become the root user:
or
If no username is specified, then the root user is assumed, so the above is often shortened to:
or
but the two commands above behave differently. 'su <user>' gives the current user the identity of <user> whereas 'su - <user>' gives the current user the identity of <user> together with <user>'s environment that would be obtained by logging in as <user>.
Often a user will become root using just 'su', try to run a command (eg, ifconfig), and get a 'command not found' error. For example:
The reason is that regular system users and the root user have different PATH environment variables. When you type a Linux command, the shell will search the user's PATH to try to locate the command to run. It starts searching each directory on the PATH until a match is found.
Often when a person reports a problem, in IRC or otherwise, they are referred to this page. In debugging WHY a given binary cannot be seen, it is helpful to view the currently effective PATH with: echo $PATH
Commands for regular users are mostly located in /usr/bin, and /bin and occasionally /usr/local/bin -- the /usr/local/* path prefix is not used for packaging by default upstream. However, root commands are mostly located in /usr/sbin, and /sbin and occasionally /usr/local/sbin As such, root's PATH reflects this.
When you become root by using 'su -', you also adopt root's PATH whereas using just 'su' retains the original user's PATH, hence why becoming root using just 'su' and trying to run a command located in /usr/local/sbin, /usr/sbin, or /sbin results in a 'command not found' error. For a more detailed explanation, see the bash manual page (man bash), particularly the section on INVOCATION and login shells.
So you either need to specify the full PATH to the command if you just used 'su' (eg, /sbin/ifconfig) or use 'su -' when becoming root.
2. Using sudo
You don't need to be root every time you want to run some specific administrative tasks. Thanks to sudo, you can run some or every command as root. Once sudo is installed (package name: sudo), you can configure it by running 'visudo' as root. Basically, it runs $EDITOR (vim as default) on /etc/sudoers, but it is not recommended to do it manually. If you are on a desktop computer, you will want to be able to do almost everything.
So, the quick and dirty way to use sudo would be to add at the end of the sudoers file :
where bob is the name of the user. Save (press escape, then type ZZ), and you are ready to go. Log in as bob, and run for example:
sudo will ask for a password. This password is bob's password, and not root's password, so be careful when you give rights to a user with sudo.
But sudo can do more. We can allow a user or group of users to run only one command, or a group of commands. Let's go back to our sudoers file (which is, by the way, well commented on CentOS 5). Let's start with bob and alice, members of a group named admin. If we want all users of the 'admin' group to be able to run every command as root, we can modify our example:
bob can still do his stuff, and alice is now allowed to run sudo, with the same rights, with her password. If bob and alice are not in the same group, we can define a user alias in the sudoers file:
here we define an alias named ADMINS, with alice and bob as members.
However, we don't want alice and bob to run every command as root, we want them to run only updatedb. Let's define a command alias:
Mac Os X Run App As Root![]()
But it's not enough! We need to tell sudo the users defined in ADMINS can run the commands defined in LOCATE. To do this, we replace the line with '%admin' with this line:
Batch rename photos app mac. it means that users of alias ADMINS can run ALL the commands in the LOCATE alias.
At this time, /etc/sudoers looks like this:
alice and bob should be able to run updatedb as root, by giving their password.
If we replace the last line of the file with:
alice and bob can run 'sudo updatedb' without entering a password.
It is possible to add more commands in a command alias and more aliases in the rule. For example, we can create an alias named NETWORKING containing some networking commands like ifconfig, route or iwconfig:
Let's add this to our /etc/sudoers file (with visudo!), and give it access to our ADMINS group of users, the /etc/sudoers now looks like this:
A little try: log in as alice (or bob), and type:
the answer should come quickly:
Skitch mac app review. Now, let's sudo it:
sudo is often used to give certain users partial access to privileged commands so that they can perform limited administrative tasks. One nice feature about sudo is that all sudo commands are logged in /var/log/secure. The above example will write this line in the log:
That's it. Now never forget, when using sudo: 'with great power comes great responsibility'.
Mac Os Run App As Root2.1. Sudo shell
If you have sufficient rights configured in sudoers you can also open a root shell by using
3. Graphical helpers3.1. GNOME
To do..
3.2. KDE
The 'Run Command..' option on the KDE Menu has the facility (under Options) to run a command or application as a different user by supplying that users credentials. Users who are less confident at the command line may like to consider this as an alternative GUI-based method for tasks that require root privileges.
Run Mac App As Root App4. consolehelper
consolehelper is a wrapper for running GUI applications. When it starts, it checks configuration of PAM for the desired application. This means that we can authenticate user with all installed PAM modules. The basic method is to ask for a password, but if we have proper hardware, we can also authenticate using smartcards, tokens, fingerprints, etc. Configuration of PAM is beyond scope of this document (see PAM Administrator's Guide), so we will only show how to configure it when we want consolehelper to run an application as root and request the root password.
As an example, let's configure /usr/bin/xterm to launch as root.
First, because we also want to retain the ability to run xterm as a normal user, we create a symbolic link named /usr/bin/xterm-root to /usr/sbin/consolehelper:
Now to configure pam - create the file /etc/pam.d/xterm-root:
Finally, configure consolehelper to run /usr/bin/xterm as the root user when started as 'xterm-root'. Create the file /etc/security/console.apps/xterm-root:
That's it. Run 'xterm-root' (from the command line or from a .desktop file), enter the root password and enyoy. If you get an error: 'Xlib: connection to ':0.0' refused by server', run 'xhost local:root' first or add the following line to the file /etc/security/console.apps/xterm-root
Be sure that the line ends with the new line character.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |