Như câu hỏi này nói, /etc/sudoerslà một tệp cấu hình trên toàn hệ thống có thể được tự động thay đổi bằng cách nâng cấp hệ thống và rất dễ bị thay đổi. Bạn có khả năng mất quyền truy cập hoặc làm cho hệ thống của bạn không thể khởi động được với một sự thay đổi không phù hợp.
$ sudo cat /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.
#
(... some other content ...)
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
Trái với những gì bạn có thể mong đợi, #includedirchỉ thị không phải là một bình luận . Nó có tác dụng gây ra sudoviệc đọc và phân tích bất kỳ tệp nào trong /etc/sudoers.dthư mục (không kết thúc bằng '~' hoặc chứa ký tự '.').
$ ls -l /etc/sud*
-r--r----- 1 root root 755 sty 20 17:03 /etc/sudoers
/etc/sudoers.d:
total 7
-r--r----- 1 root root 958 mar 30 2016 README
$ sudo cat /etc/sudoers.d/README
#
# As of Debian version 1.7.2p1-1, the default /etc/sudoers file created on
# installation of the package now includes the directive:
#
# #includedir /etc/sudoers.d
#
# This will cause sudo to read and parse any files in the /etc/sudoers.d
# directory that do not end in '~' or contain a '.' character.
#
# Note that there must be at least one file in the sudoers.d directory (this
# one will do), and all files in this directory should be mode 0440.
#
# Note also, that because sudoers contents can vary widely, no attempt is
# made to add this directive to existing sudoers files on upgrade. Feel free
# to add the above directive to the end of your /etc/sudoers file to enable
# this functionality for existing installations if you wish!
#
# Finally, please note that using the visudo command is the recommended way
# to update sudoers content, since it protects against many failure modes.
# See the man page for visudo for more information.
#
Không giống như /etc/sudoersnội dung của các bản /etc/sudoers.dnâng cấp hệ thống tồn tại, do đó, tốt hơn là tạo một tệp ở đó hơn là sửa đổi /etc/sudoers.
Bạn có thể muốn chỉnh sửa các tập tin trong thư mục này bằng visudolệnh:
$ sudo visudo -f /etc/sudoers.d/veracrypt
GNU nano 2.5.3 File: /etc/sudoers.d/veracrypt.tmp
# Users in the veracryptusers group are allowed to run veracrypt as root.
%veracryptusers ALL=(root) NOPASSWD:/usr/bin/veracrypt
Xin lưu ý rằng visudocó thể sử dụng trình chỉnh sửa khác thay vì nanođược mô tả tại https://help.ubfox.com/community/Sudoers
Dưới đây là một vài liên kết mà tôi thấy hữu ích:
/etc/sudoers.dkhông thể đưa xuống sudo. Những tập tin được nối vào/etc/sudoers. Các quy tắc tương tự áp dụng cho các tập tin.