0

I've done a mistake: I've removed the 'sudo' group, because I have forgotten the -a option (I wanted to add 'video' group):

sudo usermod -G video $USER

Now, when I want to call sudo I have this message:

orangepi@orangepi:~$ sudo apt-get update
[sudo] password for orangepi: 
Sorry, user orangepi is not allowed to execute '/usr/bin/apt-get update' as root on orangepi.

I read some solution (like visudo, or sudo adduser <username> sudo) but the problem persists. I can be root with calling su.

Some informations:

orangepi@orangepi:~$ groups
orangepi video               # I would like to add sudo, groupes and others

visudo:

Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
root    ALL=(ALL:ALL) ALL

%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

%shutdown ALL=(root) NOPASSWD: /usr/lib/arm-linux-gnueabihf/xfce4/xfsm-shutdown-helper

# Autoriser sudo ifup sans mot de passe
orangepi  ALL = (root) NOPASSWD: /sbin/ifup

How can I repair this?

2

Once you have become root via su, do:

adduser orangepi sudo

If you don't have adduser on your system, try with usermod -a to append to the groups list:

usermod -a -G sudo orangepi

You might also want to investigate which groups your user is a member of by default, and add those back as well (such as the group named after your user, adm, etc.).

Alternatively, you can use su -c:

su -c "adduser orangepi sudo"
  • Thanks, does it need a reboot? Because the groups command returns the same – Guillaume Jan 27 '15 at 13:57
  • @Guillaume No, the effect should be immediate. Did either command return an error? – muru Jan 27 '15 at 13:57
  • @muru I believe it needs at least a new login for the shell to pick up the new group membership - not a reboot, but either a logout-login or su -l $USER (or su - $USER etc.) – steeldriver Jan 27 '15 at 14:00
  • @steeldriver that's true if you were to try sg or some command which needed that group membership, but not for the groups command itself. – muru Jan 27 '15 at 14:01
  • After reboot, it works. I've added adm too, I havn't tried. Thanks a lot – Guillaume Jan 27 '15 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.