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

改成没密码,

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为不需要密码

linux设置sudo不要密码的更多相关文章

  1. mac上设置sudo不要密码

    觉得每次sudo都需要设置密码太过麻烦,于是折腾了一番,谁知走了一番弯路记录下来. 以下是网上找到的步骤 chmod u+w /etc/sudoers  给当前用户增加写权限 vi /etc/sudo ...

  2. Linux之sudo免密码操作

    使用普通用户只需特权命令是需要输入密码,然后在五分钟以内只需命令可以免密码,下面设置免密码操作 系统环境查看 切换至root用户 sudo -i #需要输入密码 修改sudoers文件 #增加一行 y ...

  3. linux设置系统用户密码

    目录 一:系统用户密码 1.设置用户密码 一:系统用户密码 1.设置用户密码 1.交互式方法 passwd [用户名] 2.免交互式 echo [设置密码] | passwd --stdin [用户名 ...

  4. Linux 设置代理时, 密码出现特殊字符怎么办?

    配置代理的格式一般是这样的: $ export https_proxy=https://用户名:密码@代理地址:代理端口 比如需要配置这些: $ export http_proxy=http://Co ...

  5. linux 设置git记住密码

    linux下: 1.在~/下, touch创建文件 .git-credentials, 用vim编辑此文件,输入: https://{username}:{password}@github.com 注 ...

  6. ubuntu 设置sudo 免密码

    一. 修改sudoers的权限 二. 修改sudoers 文件 <1>. 在文件最后一行添加yourusername ALL=(ALL) NOPASSWD : ALL 三. 修改回sudo ...

  7. linux设置su和sudo为不需要密码

    一 设置sudo为不需要密码   有时候我们只需要执行一条root权限的命令也要su到root,是不是有些不方便?这时可以用sudo代替.默认新建的用户不在sudo组,需要编辑/etc/sudoers ...

  8. linux下普通用户添加 sudo 免密码

    在使用普通用户登录的时候,会经常使用sudo指令执行一些操作,有时候感觉输入密码比较繁琐,特别是需要设置一些开机启动的时候操作,而这些操作往往就需要sudo指令,如果没有免密的话,在使用普通用户登录的 ...

  9. Linux centosVMware MySQL常用操作设置更改root密码、连接mysql、mysql常用命令

    一.设置更改root密码 启动mysql /usr/local/mysql/bin/mysql -uroot 更改环境变量PATH,增加mysql绝对路径 使mysql -uroot永久生效需要编辑, ...

随机推荐

  1. python smtp登陆邮箱失败

    >>> server.connect('smtp.163.com') (220, b'163.com Anti-spam GT for Coremail System (163com ...

  2. 基于centos7.6离线部署开k3s

    K3S简介: https://k3s.io/ https://github.com/rancher/k3s https://github.com/rancher/k3s/releases      / ...

  3. golang之reflection

    反射就是程序能够在运行时检查变量和值,求出它们的类型. reflect包实现运行时反射. 创建一个接收任何数据类型任何数值的查询string: func createQuery(q interface ...

  4. NGINX状态模块的使用

    nginx状态模块可以用来查看当前nginx服务器的并发量和总的请求数 启用nginx的状态模块 状态模块需要在编译安装的时候启用. 1.下载nginx源码包 2.安装nginx并启用模块 3.修改n ...

  5. O(n) 取得数组中每个元素右边第一个比它大的元素

    题目: 给定一个整型数组,数组元素随机无序的,要求打印出所有元素右边第一个大于该元素的值. 如数组A=[6,8,9,2,3,5,6] 输出[8,9,-1,3,5,6,-1] 思路: 我们用栈来保存未找 ...

  6. tkinter改进了随机显示图片

    随机显示,还加了圆圈,这样感觉更好点. from django.test import TestCase # Create your tests here. import random import ...

  7. Android Handler机制彻底梳理

    Android的消息机制其实也就是Handler相关的机制,对于它的使用应该熟之又熟了,而对于它的机制的描述在网上也一大堆[比如15年那会在网上抄了一篇https://www.cnblogs.com/ ...

  8. 牛客1024B 石头游戏

    题目描述 石头游戏在一个 \(n\) 行 \(m\) 列 \((1\leq n,m \leq 8)(1≤n,m≤8)\) 的网格上进行,每个格子对应一种操作序列,操作序列至多有10种,分别用0~9这1 ...

  9. Python练习题——用列表的方法输出杨辉三角

    def main(): num = int(input('请输入行数: ')) yh = [[]] * num #创建num行空列表 for row in range(len(yh)): #遍历每一行 ...

  10. 【pathon基础】初识python

    一.python的起源 作者:Guido van Rossum(龟叔) 设计原则:优雅,简单,明确 二.解释型语言VS编译型语言 1.解释型语言:C#.python step1:程序员写代码: ste ...