linux改sudo密码_linux怎么给用户权限

linux改sudo密码_linux怎么给用户权限linux设置sudo不要密码

大家好,又见面了,我是你们的朋友全栈君。

linux下,普通用户,sudo时需要密码

linux改sudo密码_linux怎么给用户权限

改成没密码,

vi /etc/sudoers

在 root ALL=(ALL) ALL后加一行

sysusr ALL=(ALL) NOPASSWD: ALL  (92行)

有时将用户设了nopasswd,但无效,原因是被后面的group的设置覆盖了,需要把group的设置也改为nopasswd。

sysusr账号所在组(wheel):见102行,%wheel,设置用户组sudo不加密,保存即可生效。
   ...
81 ## Next comes the main part: which users can run what software on 82 ## which machines (the sudoers file can be shared between multiple 83 ## systems). 84 ## Syntax: 85 ## 86 ## user MACHINE=COMMANDS 87 ## 88 ## The COMMANDS section may have other options added to it. 89 ## 90 ## Allow root to run any commands anywhere 91 root ALL=(ALL) ALL 92 sysusr ALL=(ALL) NOPASSWD: ALL 93 94 ## Allows members of the 'sys' group to run networking, software, 95 ## service management apps and more. 96 # %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS 97 98 ## Allows people in group wheel to run all commands 99 %wheel ALL=(ALL) ALL 100 101 ## Same thing without a password 102 # %wheel ALL=(ALL) NOPASSWD: ALL //这一行的#要放开,效果上,覆盖99行的设置 103 104 ## Allows members of the users group to mount and unmount the 105 ## cdrom as root 106 # %users ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom 107 108 ## Allows members of the users group to shutdown this system 109 # %users localhost=/sbin/shutdown -h now 110 111 ## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment) 112 #includedir /etc/sudoers.d

 附录:查看用户所在组的两个方式:

1.groups命令

[sysusr@GCOS 12:15:58]$ groups
sysusr wheel service <~>

2.查看/etc/group

[sysusr@GCOS 12:18:49]$ cat /etc/group|grep sysusr
wheel:x:10:sysusr
sysusr:x:1000:service,postgres,mysql,nginx,apache
service:x:2000:sysusr,postgres,mysql,nginx,apache
<~>

 参考:

设置su和sudo为不需要密码

转载于:https://www.cnblogs.com/xiaoliu66007/p/11089072.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/106752.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 二叉树计算叶子节点的计算问题

    二叉树计算叶子节点的计算问题题目如下:计算方法需要使用两个结论:1:总结点数=树中的边数+1。见下图可以清晰明白。2:叶子节点数=总结点数-度数非零的节点数(戒子节点度为0)所以本题目解法:总结点数=20*4+10

    2022年8月1日
    7
  • 一文读懂Spring 循环依赖,写得太好了!(建议收藏)

    点击上方“全栈程序员社区”,星标公众号 重磅干货,第一时间送达 转自:Vt 链接:juejin.im/post/5e927e27f265da47c8012ed9 前言 Spring…

    2021年6月23日
    89
  • 单幅图像超分辨率重建(图像超分)

    代码的解析已经给出,现在补上:单图像超分辨率重建示例代码解析目录一、简介二、前期准备三、运行程序四、参考目录一、简介图像超分辨率重建技术就是利用一组低质量、低分辨率图像(或运动序列)来产生单幅高质量、高分辨率图像。图像超分辨率重建应用领域及其宽广,在军事,医学,公共安全,计算机视觉等方面都存在着重要的应用前景。在计算机视觉领域,图像超分辨率重建技术有可能使图像实现从检出…

    2022年4月17日
    203
  • WinExec执行批处理命令

    WinExec执行批处理命令proceduredeleteDirtyRz;varstr:string;beginstr:=’del’+appPath+’USedLog\*.log’;WinExec(PChar(‘cmd.exe/c’+str),SW_HIDE);end;加了/c参数后它将运行/c后面的命令不加参数的话,它只执行CMD命令.解析:doc输入:CMD/?启…

    2022年7月11日
    14
  • 边界网关协议BGP_可信边界安全网关

    边界网关协议BGP_可信边界安全网关文章目录边界网关协议BGP协议详解最全BGP路由协议技术详解

    2025年7月11日
    2
  • 【Python】 【绘图】plt.figure()的使用

    【Python】 【绘图】plt.figure()的使用1.figure语法及操作(1)figure语法说明figure(num=None,figsize=None,dpi=None,facecolor=None,edgecolor=None,frameon=True)num:图像编号或名称,数字为编号,字符串为名称 figsize:指定figure的宽和高,单位为英寸; dpi参数指定绘图对象的分辨率,即每英寸多少个像素,…

    2022年6月29日
    49

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号