I made a new user on my Raspberry Pi for myself and it keeps asking for my password when I do things like sudo apt-get install. How do I make it an administrator?

  • Explained on Raspberry’s web site – Guy . D May 7 '18 at 13:02

You can manually add the user to sudoers, but this is only part of the story.

If you want the user to have the same privileges you should set the groups. The pi user is normally a member of pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi

This can be done with the following command (replace username with the actual name).

for GROUP in $(groups pi | sed 's/.*:\spi//'); do sudo adduser username $GROUP; done

(the sed command is there to remove group pi so the new user does not share files with pi)

NOTE editing the sudoers file is NOT recommended - many have broken their systems by getting this wrong.

| improve this answer | |

On Raspbian you have two common options:

Option 1: Add the already created user (i.e. with the name "john") to the group "sudo":

pi@raspberry:~ $ sudo usermod -aG sudo john

Option 2: Edit the sudoers file:

pi@raspberry:~ $ sudo visudo

By default you'll find this line (do not remove/overwrite it): root ALL=(ALL:ALL) ALL. Just add john ALL=(ALL:ALL) ALL' or, if you want passwordless root access, add john ALL = NOPASSWD: ALL.

visudo provides basic sanity checks, parses the sudoers file after your edit and will not save your changes if there is a syntax error. I'd not recommended to use other tools like nano for this job.

Reboot is not required, but for security reasons only a sudoer user can make these changes.

| improve this answer | |
  • Of course to run this command requires you to login as the Pi user (or another user with root privileges). – joan May 6 '18 at 9:15

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.