gpt4 book ai didi

linux - 使用 sudoers 无需密码即可运行脚本

转载 作者:太空宇宙 更新时间:2023-11-04 05:15:38 29 4
gpt4 key购买 nike

我正在尝试运行一个自动调整屏幕背光的脚本,这需要它以提升的速度运行。

因此,我尝试将其添加到我的 sudoers 文件中,这样我就可以在没有脚本的情况下运行它。

不幸的是,我似乎无法让它发挥作用。

该文件位于/usr/local/bin/backlight.sh

有什么建议吗?我对 Linux 的这一部分有点陌生......

/etc/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:/snap/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
username ALL=( root ) NOPASSWD: /usr/local/bin/backlight.sh

最佳答案

我怀疑您的用户是“用户名”。更改您的行并将“用户名”替换为您的实际用户。

例如。我的用户是nic。 sudoers 将是:

nic ALL=(root) NOPASSWD:/usr/local/bin/backlight.sh

关于linux - 使用 sudoers 无需密码即可运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49848463/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com