我创建了几个别名,并将其来源到 shell:
alias apti="apt-fast install -y"
alias aptr="apt-fast remove -y"
alias aptp="apt-fast purge -y"
alias apts="aptitude search"
alias aptu="sudo dpkg --configure -a; apti -f; apt-fast update; apt-fast upgrade -y; apt-fast full-upgrade -y; apt-fast autoremove -y"
然后向 /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
Cmnd_Alias APT=/usr/local/bin/apt
Cmnd_Alias DPKG=/usr/bin/dpkg
Cmnd_Alias APTGET=/usr/bin/apt-get
Cmnd_Alias APTITUDE=/usr/bin/aptitude
Cmnd_Alias APTFAST=/usr/sbin/apt-fast
Cmnd_Alias PM_SUSPEND=/usr/sbin/pm-suspend
myuser ALL=(ALL:ALL) NOPASSWD: APT, DPKG, APTGET, APTITUDE, PM_SUSPEND, APTFAST
多年来一直运行良好。但几周前(linux mint 更新?)它开始给我错误。
$ apti iridium-browser
sudo: sorry, you are not allowed to set the following environment variables: DEBUG, LCK_FILE, DOWNLOADBEFORE, _APTMGR, APTCACHE, DLDIR, DLLIST, LISTDIR, _MAXNUM, _MAXCONPERSRV, _SPLITCON, _MINSPLITSZ, _PIECEALGO, aptfast_prefix, APT_FAST_TIMEOUT
在 /etc/sudoers.d 中,我有两个文件:README 和 mintupdate。我没有编辑过其中任何一个。唯一没有注释的行是:
Cmnd_Alias UPDATE = /usr/lib/linuxmint/mintUpdate/checkAPT.py
ALL ALL = NOPASSWD:UPDATE
据我所知,我没有设置列出的任何环境变量。我究竟做错了什么?
答案1
在 lazarus 程序中将“sudo 命令”作为进程执行时,我也收到此错误消息,但是当我将其更改为“/usr/bin/sudo 命令”时,它工作正常,没有错误,所以在我的情况下,正是缺少“sudo”路径才产生错误。