1

I have a Linux user that needs to be able to execute any command with sudo, but it should ask for their password for all apart from one executable. Currently my sudoers files looks like:

#
# 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) NOPASSWD:/bin/switch.sh

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

#includedir /etc/sudoers.d

So I have added my user to the sudo group, however I think I have the syntax wrong as now I can only execute switch.sh with sudo and no others

  • Just making sure: 1) When we talk about the "password" we talk about the user's password, NOT root's password. I know duh, but sometimes people are confused. 2) In order to test change to /etc/sudoers I usually have to logout/login or start a new shell respectively. Make sure you remember that while testing. – Marki Nov 16 '14 at 19:51

1 Answers1

0

For %sudo group users to allow anything but /bin/switch.sh you need the first line. The second line allow user in %sudo execute all with password, but as the first line have precedence, users must type the password all but script on first line.

%sudo    ALL=(root) NOPASSWD:/bin/switch.sh
%sudo    ALL=(ALL) ALL
jherran
  • 3,939
  • I want all users that are in the group sudo to follow the same rule. Also I would rather if possible have it to users in sudo have to give a password for all command apart from switch.sh – DevWithZachary Nov 16 '14 at 19:30