理解sudo和sudoers
在 Linux 上, 只有 root 用户可以执行任何命令, 其他用户必须使用 sudo 才可执行特殊的命令.
sudo 是通过 sudoers 进行配置的.默认配置
/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 复制代码添加配置
不建议直接修改默认配置文件, 我们可以使用 #include 和 #includedir 添加自定义的配置文件.
/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. # 复制代码理解配置root ALL=(ALL:ALL) ALL 复制代码
上面的配置表示: root 用户可以在 任意机器 上以 任意用户 和 任意用户组 的 任意组合 执行 任意命令.root: 用户 (%admin 表示 用户组)ALL=: 所有 host (sudoers 配置可能被用到多台机器上)ALL:: 任意 用户:ALL: 任意 用户组ALL: 任意 命令常见配置
允许用户使用 sudo 执行任意命令, 但需要输入用户密码user ALL=(ALL:ALL) ALL 复制代码
允许用户不需要密码使用 sudo 执行任意命令user ALL=(ALL:ALL) NOPASSWD: ALL
作者:K8sCat
链接:
https://juejin.cn/post/6913405166297284621
空气净化器更换过滤器时需要注意哪些问题?对于大部分空气净化器,通常会使用H13或H14级HEPA高效滤网与活性炭组合使用,针对空气中的颗粒污染物和异味有较好的净化作用。像这种物理过滤的耗材,在使用过程中如果需要更换,需要
活性炭在过滤类空气消毒机应用活性炭是由有机物(木材果壳椰壳等)在隔绝空气条件下燃烧,减少非木质成分的量(这过程也可称之为有机物的炭化过程)。经过炭化过程后,其与空气接触后会被活化,形成无数个微小孔隙,活性炭的
适用于公共场所的空气消毒机有哪些特点?除了办公室家里等室内的空气质量外,门诊大厅汽车站火车站地铁站超市等公共场所的空气质量同样值得被关注。对于公共车站,在周末节假日等休假时间较长的时间段里,公共车站的人流量会特别多,像
室内这些隐形污染,一台空气消毒机解决据了解,很多建筑物内的空气污染是室外空气污染的几倍甚至数十倍,很多人会有这样的疑惑,明明并没有看见室内空气中含有污染物,为何还会空气污染比较严重?原因是很多污染物呈气态形式,而且是
三千档手机最强对决,你会心仪谁?三千档是目前国产旗舰手机的主流价位,也是机型最多,竞争最激烈的价位。许多网友选择旗舰手机应该都会考虑这个价位的手机。在目前的2999价位上,出现了两款性价比最高的旗舰手机,它们分别
四年前的苹果6s,相当于现在什么级别?尽管不想承认,目前苹果手机的性能配置,依然很顶尖,从处理器的跑分,就可见一斑,同一代处理器,华为的麒麟990,以及高通的骁龙855plus,单核跑分都是12000左右,但苹果A13
华为手机别乱买,这三款一定要注意华为旗下的荣耀品牌手机主打性价比,广受大众喜爱,不少畅销机型甚至胜过华为的高端旗舰机,也算是华为手机的主力军。但荣耀手机也依旧不能乱买,以下这三款机型,虽均有不同幅度的降价,且最低
这4款最佳的千元机,外观精致配置给力很多时候消费者在购买手机的时候最看重的还是产品的性价比吧!在当下手机市场其实最不缺乏的就是超高的性价比了吧!华米OV都没有坐以待毙,拿出了高端的旗舰手机的同时,也不忘记在千元机最大
百时美施贵宝公司BristolMyersSquibb视觉形象升级百时美施贵宝(BristolMyersSquibb)成立于1887年,是一家以科研为基础的全球性的从事医药保健及个人护理产品的多元化企业,其主要业务涵盖医药产品日用消费品营养品及医
人工智能公司Covariant视觉形象设计Covariant成立于2017年,是一家总部设在加州伯克利的公司,专注于人工智能。具体的说,就是构建通用的人工智能(AI),使机器能够查看推理并对周围的世界采取行动。两个月前,他
护肤品品牌OioLab视觉形象升级OioLab成立于2019年,是在波兰生产和销售的护肤品品牌,由JoannaRyglewicz创立,目前提供四种面部护理油,以天然成分为基础,包括有机冷榨油和通过创新方法获得的植物