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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • android gradle下载慢的解决方法

    android gradle下载慢的解决方法用androidstudio开发时,导入的项目经常会用到各种gradle版本,不知道为何androidstudio下载gradle极慢,最后总是失败。https://services.gradle.org/distributions/这是gradle各版本的官方网站。在这网站上下载速度很快。下载的文件放哪里呢?放到以下对应的目录中。C:\Users\admin\.gradle\wrapper\dists\gradle-6.7-all\cuy9mc7upwgwgeb72wkcrup

    2022年6月24日
    31
  • 简单的udp攻击_udp flood攻击

    简单的udp攻击_udp flood攻击由于本人很菜,这个代码是改别人的.呵呵.可以在公司的局域网里搞搞坏,呵呵.我是在ubuntu8.04下的,需要gcc编译.这个也添加了广播,整个网段的人都能收到了#include#include#include#include//ip#include//tcp#include#includeunsignedshortip_su…

    2022年10月2日
    4
  • 执行力与领导力

    执行力与领导力

    2021年8月20日
    63
  • layer执行父窗口ajax方法,layer 弹出层 回调函数调用 弹出层页面 函数

    layer执行父窗口ajax方法,layer 弹出层 回调函数调用 弹出层页面 函数1、项目中用到layer弹出层,定义一个公用的窗口,问题来了窗口弹出来了,如何保存页面上的数据呢?疯狂百度之后,有了结果,赶紧记下。2、自己定义的公共页面方法:layuiWindow:function(options){vardefaults={title:’添加菜单’,width:’100px’,height:’100px’,url:”,shade:0.3,btn:[…

    2022年7月15日
    15
  • 《转》OpenStack Live Migration[通俗易懂]

    《转》OpenStack Live Migration

    2022年1月23日
    41
  • C语言 函数指针和指针函数及Main()函数

    C语言 函数指针和指针函数及Main()函数正文先来看看两者的定义以及说明。指针函数定义指针函数,简单的来说,就是一个返回指针的函数,其本质是一个函数,而该函数的返回值是一个指针。声明格式为:类型标识符*函数名(参数表)这似乎并不难理解,再进一步描述一下。看看下面这个函数声明:intfun(intx,inty);这种函数应该都很熟悉,其实就是一个函数,然后返回值是一个int类型,…

    2022年6月22日
    24

发表回复

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

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