사용자가 sudo를 사용하여 무엇이든 실행할 수 있도록 허용합니다. 단 하나의 실행 파일만 nopassword로 실행 가능합니다.

사용자가 sudo를 사용하여 무엇이든 실행할 수 있도록 허용합니다. 단 하나의 실행 파일만 nopassword로 실행 가능합니다.

sudo를 사용하여 모든 명령을 실행할 수 있어야 하는 Linux 사용자가 있는데 하나의 실행 파일을 제외한 모든 명령에 대해 비밀번호를 요청해야 합니다. 현재 내 sudoers 파일은 다음과 같습니다.

#
# 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

그래서 내 사용자를 sudo 그룹에 추가했지만 지금은 sudo로만 switch.sh를 실행할 수 있고 다른 것은 실행할 수 없기 때문에 구문이 잘못된 것 같습니다.

답변1

%sudo그룹 사용자가 무엇이든 허용하려면 첫 /bin/switch.sh번째 줄이 필요합니다. 두 번째 줄에서는 사용자가 %sudo암호를 사용하여 모두 실행할 수 있지만 첫 번째 줄이 우선하므로 사용자는 첫 번째 줄에 스크립트를 제외한 모든 암호를 입력해야 합니다.

%sudo    ALL=(root) NOPASSWD:/bin/switch.sh
%sudo    ALL=(ALL) ALL

관련 정보