Tuesday, October 30, 2007

Ubuntu: sudo woes

Ubuntu's philosophy is to have a privileged "first user" account, created during system setup, which has sudo privileges. There is also a separate user account with username "root", but the password is unknown right after installation. The system administrator is expected to administer the system through the privileged first user account.

To get access to the root account, you can use the command "sudo passwd root" as the privileged user to reset the root password.

Suppose you want to run a package manager as the privileged first user, while logged in as a regular (non-privileged) user in Gutsy Gibbon (Ubuntu 7.10). You cannot use sudo unless the non-privileged user is in the sudoers group. Attempting something like the command "gksudo -u privileged-username package-manager" brings up a root password prompt, but you always get an "incorrect password" error. Using gksu also results in the same problem. However, using su in a terminal rather than gksudo or gksu works.

Fix:

The reason this doesn't work is that gksu's behaviour defaults to gksudo (see gksu man page). A solution:

1. Reset root password using "sudo passwd root" as the privileged user
2. Then "gksu --su-mode package-manager" to run it as root.

I still don't know how to make this work running the package manager as the privileged user rather than root.




No comments: