Search:  
Gentoo Wiki

TIP_No_More_sudo_emerge

Contents

No More 'sudo emerge'

One of the things I was excited about with the Gentoo OS X install was that as an underprivileged user, you could type emerge and it would ask you for your password, much like running sudo emerge world.

The setup for sudo

Make sure you have sudo installed, and the user is able to sudo (is part of the wheel group).

emerge -n sudo
gpasswd -a user wheel 
gpasswd -a user portage

(Make sure you typed in the user you want to be able to do this, and not the string user)

Another way of setup for sudo

In order for a regular user to be able to launch emerge, the user must be given additional privileges. You should always edit your sudoers file using the visudo command as root. This command uses your default editor to make the changes then does some syntax checking. The sudoers file is quite delicate!
So run visudo:

File: /etc/sudoers
user ALL=(ALL) NOPASSWD: /usr/bin/emerge

(Make sure you typed in the user you want to be able to do this, and not the string user)

Another Way, Configuration for you

Simply put the following in your ~/.bashrc and you'll be finished.

File: ~/.bashrc
alias emerge="sudo emerge"

Now either log out and back in, or source ~/.bashrc and you'll be asked for the password whenever you emerge something as a non-root user.

USE Variables

Sometimes you might want to specify certain USE variables once.

USE="-* kde" emerge azureus-bin

Would normally emerge azureus-bin with ONLY the kde flag.
By default sudo resets most of your variables so you'll have to add a line to your /etc/sudoers file.

File: /etc/sudoers
Defaults:user env_keep=USE

(Make sure to replace user with the user you are setting this all up for, or %group if you want to use a specific group of users)

If you didn't create an alias to run emerge like shown above, the USE="...." part of the command still goes first:

USE="nls" sudo emerge gnome

For more info on sudo take a look at http://www.gentoo.org/doc/en/sudo-guide.xml

Retrieved from "http://www.gentoo-wiki.info/TIP_No_More_sudo_emerge"

Last modified: Mon, 08 Sep 2008 05:58:00 +0000 Hits: 22,871