You are not logged in.

#1 2020-09-13 12:21

Keller_HP-Compaq
Member
Registered: 2020-09-11
Posts: 5

NOPASSWD: is not working

Hello,
i have the problem that i tried to set up some keyboard
shortcuts with custom commands that require root privileges.

I want to be able to execute the command
"sudo pm-suspend" with a key combination.

So I did it the same way I did it on another Ubuntu pc before:

I opened the "/etc/sudoers" file with "sudo visudo" and added the line:

"jonas ALL = NOPASSWD: /usr/sbin/pm-suspend"

But this currently only works if I have previously opened
a terminal and executed some command with "sudo".

On ubuntu this always worked without problems.

Does anyone have an idea how I can fix this ?
To make the key combination work ?

Offline

#2 2020-09-13 12:35

q4osteam
Q4OS Team
Registered: 2015-12-06
Posts: 4,223
Website

Re: NOPASSWD: is not working

That should ordinarily work on Debian/Q4OS, did you edit sudoers file correctly, with no typo ?

Offline

#3 2020-09-13 13:50

Keller_HP-Compaq
Member
Registered: 2020-09-11
Posts: 5

Re: NOPASSWD: is not working

This is my "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

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

# Allows the user jonas to run the command »sudo pm-suspend« (Bereitschaft) without typing password
jonas   ALL = NOPASSWD: /usr/sbin/pm-suspend

#Allows the user jonas to run the command »sudo shutdown now« (Herunterfahren) without typing password
jonas   ALL = NOPASSWD: /usr/sbin/shutdown now

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

#includedir /etc/sudoers.d

Offline

#4 2020-09-13 13:57

Keller_HP-Compaq
Member
Registered: 2020-09-11
Posts: 5

Re: NOPASSWD: is not working

I have inserted a small description of the command, as with the other lines, to remind me of their function.
But because of the # this should not be a problem.

Offline

#5 2020-09-15 10:51

q4osteam
Q4OS Team
Registered: 2015-12-06
Posts: 4,223
Website

Re: NOPASSWD: is not working

Yes, we can confirm your directive is correct and it doesn't work, as it's overriden with another directive in /etc/sudoers.d/ directory. You only need to place it after that directive, so if you edit sudoers file, just place your directive bellow the "#includedir /etc/sudoers.d" line. Another way would be to place your directive in a custom file, for example: "/etc/sudoers.d/99-my-directives"

Offline

Board footer

Powered by FluxBB