Sphere
Log in Join
☆ 2

user is in sudo group but sudo still says not in sudoers

Added a user with usermod -aG sudo alice on Debian 12, and sudo still says alice is not in the sudoers file. This incident will be reported. id alice shows the sudo group. I had her log out and back in. There is a file in /etc/sudoers.d with her name in it, mode 0644, but I'm not sure it's syntactically valid. What should I check?

⚑ Report

4 replies

☆ 0
Y yaml ·2026-10-03#1

Two things. First, files in /etc/sudoers.d must be mode 0440 or sudo ignores them, and 0644 is too permissive. Second, validate syntax with visudo -c -f pointing at that file before changing anything. A bad line there won't show up in a plain visudo -c on the main file.

⚑ Report
☆ 0
C cron48 ·2026-10-03#2

visudo -c -f found a syntax error: the line was alice ALL=(ALL) NOPASSWD: ALL but with a trailing comment that had a stray quote in it. I fixed the line, chmod 0440, and sudo works now. The group membership was fine all along, the drop-in was being ignored because of permissions and then broken because of syntax.

⚑ Report
☆ 0
R rust21 ·2026-10-13#3

Use visudo -f /etc/sudoers.d/alice to edit it, not a normal editor. visudo locks the file and checks syntax before saving, so you can't lock yourself out with a typo. And prefer a group-based rule like the sudo group rule in the main file over per-user drop-ins when you're adding several people.

⚑ Report
☆ 0
G ghost ·2026-10-18#4

Also check for requiretty or Defaults interactions if it still asks for a password unexpectedly. On Debian 12 the default sudoers file has the sudo group rule enabled, so if the drop-in is broken you could just rely on that instead. Simpler is better here.

⚑ Report
Log in to reply.