1

After installing PiNet on my Ubuntu machine, I noticed that sudo is no longer prompting me for a password. This is still the case after rebooting or after running sudo -k:

$ whoami 
thang 
$ sudo whoami 
root 
$ sudo -k 
$ sudo whoami 
root

As you can see above, no password prompt was printed. The thang user is not UID 1:

$ grep thang /etc/passwd 
thang:x:1000:1000:thang,,,:/home/thang:/bin/bash

And there doesn't seem to be anything strange in my /etc/sudoers file:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

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

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

There is also a file called 01staff in /etc/sudoers.d:

$ cat /etc/sudoers.d/01staff
%teacher ALL=NOPASSWD: ALL

In case it's relevant, the groups that thang belongs to are:

$ groups thang 
thang : thang adm dialout cdrom sudo audio dip video plugdev games users input lpadmin sambashare pupil teacher

Running GUI programs that require root access still prompts me for a password but terminal commands do not. What is going on here?

9
  • Please edit your question and add output of sudo cat /etc/sudoers terminal command.
    – Pilot6
    Sep 30, 2015 at 16:05
  • @Pilot6 I added it. I think that nothing's wrong with it.
    – thangdc94
    Sep 30, 2015 at 16:37
  • There is a timeout. You do not need to enter the password again if you entered it once. If you close the terminal and start it again, does it ask for a password?
    – Pilot6
    Sep 30, 2015 at 16:40
  • I restarted my computer, but it still occured. Can I fix it with a live USB.
    – thangdc94
    Sep 30, 2015 at 16:45
  • What user are you logging in as? Sounds like you're logged in as "root".
    – terdon
    Sep 30, 2015 at 16:54

1 Answer 1

2

Apparently, installing PiNet created the teachers group, added your user to it and also created the file in /etc/sudoers.d. This line:

%teacher ALL=NOPASSWD: ALL

Gives the right to all members of the teachers group to run sudo commands without providing a password. So, simply delete it and you should be fine:

sudo rm /etc/sudoers.d/01staff

PiNet seems to be a program to facilitate administrating a classroom full fo Pis and, apparently, believes that all teachers should have passwordless sudo rights.

If you do actually want to keep that setup, just remove your user from the teachers group:

sudo usermod -G  adm dialout cdrom sudo audio dip video plugdev games users input lpadmin sambashare pupil 
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .