Linux 上, 只需 root 用户能够实施任何指令, 其他用户有必要运用 sudo 才可实施特别的指令.

sudo 是通过 sudoers 进行装备的.

默许装备

/etc/sudoers:

#
# This file Mlinux是什么操作体系UST be edited with the 'visudo' command as root.
#
# Please consider adding local content inlinux体系 /etc/sudolinux体系安装ers.d/ instead of
# directly modifying this file.
#
# See the man page for detubuntu怎样设置中文ails on how toUbuntu wlinux是什么操作体系rite a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpaubuntu换源ss
Defaults        secure_path="/usr/local/sbin:/usr/local/linux必学的60个指令bin:/usr/sbin:/usrubuntu20.04安装教程/bin:/sbin:/bin:/snap/bin"
# Hostlinux操作体系基础知识 alias specificationubuntu体系
# User aliaslinux是什么操作体系 specification
# Cmnlinux操作体系基础知识d alias specificationubuntu体系菜鸟入门
# User privilege specification
root    ALL=(ALL:ALL) ALL
# Members of the admin groulinux重启指令p may gain root privileges
%admin ALL=(ALL) ALL
# Aubuntu体系菜鸟入门llow members of group sudo to elinux创建文件xecute aubuntu和linux的差异ny command
%sudo   ALL=(ALL:ALL)linux ALL
# See sudoelinux操作体系基础知识rs(5) for more information on "#include" directivesubuntu怎样设置中文:
#includedir /etc/subuntu安装教程udoers.d

增加装备

不建议直接批改默许装备文件, 我们能够运用 #ubuntu体系菜鸟入门include#includedir 增加自定义的装备文件.

/etc/sudoersUbuntu.d/README:

#
# As of Debian versionubuntu体系 1.ubuntu怎样读7.2p1-1, the default /etc/sudoers file created on
# installation of the package now includes the directive:
#
#       #includedir /etc/sudoelinux指令rs.d
#linux常用指令
# This will cause sudo to read and parse any files in the /etc/sudoers.d
# directory that do not elinux体系安装nd 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 044ubuntu网络配置0.
#
# Note also, that because sulinux是什么操作体系doers contents can vary widely, no atubuntu怎样设置中文tempt is
# made to add this dilinux常用指令rective to existing sudoers files olinux是什么操作体系n upgrade.  Feel free
# to add the above directivlinux必学的60个指令e to the end of your /etc/sudubuntu怎样读oelinux必学的60个指令rs file to enable
# this functionality for existing installationlinux指令s if you wish!
#
# Finally, plinux必学的60个指令lease note that using the visudo commalinux是什么操作体系nd is the recommended way
# to update sudoers content, since it protlinux体系安装ects against many failure modes.
# See the man page for visudo for more information.
#

了解装备Ubuntu

rolinux是什么操作体系ot    ALL=(ALL:ALL) ALL

上面的装备标明: root 用户能够在 恣意机器 上以 恣意用户恣意用户组恣意组合 实施 恣意指令.

  • root: 用户 (%admin 标明 用户组)
  • ALL=: 全部 host (sudoers 装备或许被用到多台机ubuntu和linux的差异器上)
  • ALL:: 恣意 用户
  • :ALL: 恣意 用户组
  • ALL: 恣意 指令

常见装备

容许用户运用 sudo 实施恣意指令, 但需求输入用户暗码

user ALUbuntuL=(ALL:ALL) ALL

容许用户不Linux需求暗码运用 sudo 实施恣意指令

uselinux常用指令r ALL=(ALL:ALL) NOPASSWD: ALL

参阅文档

  • [What is the difference between root ALL=(ALL:ALLubuntu怎样读) ALL and root ALL=(ALL) ALL?

](askubuntu.ubuntu怎样设置中文com/questions/5…)

  • Sudoers file,ubuntu怎样设置中文 enable NOPASSWD for user, all commands
  • Sudoers Manual

原文链接: k8scat.comubuntu和linux的差异/posts/linux…

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。