CentOS7配置sudo

如果一些用户共享权限,配置sudo是为了分离用户的职责

1. 将root 的权限传递给所有用户

[root@centos7 ~]# visudo

添加下面的内容到最后一行,使jack拥有root的所有权限

jack ALL=(ALL) ALL

[root@centos7 ~]# su - jack

Last login: Fri Oct 27 06:52:31 CST 2017 from 192.168.1.100 on pts/0

[jack@centos7 ~]$ /usr/bin/cat /etc/shadow

/usr/bin/cat: /etc/shadow: Permission denied

[jack@centos7 ~]$ sudo /usr/bin/cat /etc/shadow

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.

#2) Think before you type.

#3) With great power comes great responsibility.

[sudo] password for jack:

root:$6$LpF2wUDowE.JSaw1$Gg8PQluOh2el9dFgzsgd/YwiCy9pw9.nAVvmV3lQwwj9gbZqySmsU2xxvvPId1mJ6mUSd04FPMhD.1jV5aKpp0::0:99999:7:::

bin:*:17110:0:99999:7:::

daemon:*:17110:0:99999:7:::

adm:*:17110:0:99999:7:::

lp:*:17110:0:99999:7:::

2. 配置一些命令不能通过sudo执行

[root@centos7 ~]# visudo

在Cmnd_Alias后一行添加

Cmnd_Alias USERMGR = /usr/sbin/useradd, /usr/sbin/userdel, /usr/sbin/usermod, /usr/bin/passwd'

在最后一行添加

%usermgr ALL=(ALL) USERMGR

[root@centos7 ~]# groupadd usermgr

[root@centos7 ~]# usermod -G usermgr jack

[jack@centos7 ~]# sudo /usr/sbin/useradd testuser

[jack@centos7 ~]# sudo /usr/bin/passwd testuser

Changing password for user testuser.

New password:

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:

passwd: all authentication tokens updated successfully.

3. 传递root的部分权限到用户的sudo

[root@centos7 ~]# visudo

添加下面的内容到最后一行,使各用户拥有root的部分权限

jack ALL=(ALL) /usr/sbin/visudo

fedora ALL=(ALL) /usr/sbin/useradd, /usr/sbin/userdel, /usr/sbin/usermod, /usr/bin/passwd

ubuntu ALL=(ALL) /bin/vi

CentOS7系列--1.6CentOS7配置sudo的更多相关文章

  1. CentOS7系列--1.5CentOS7配置vim

    CentOS7配置vim 1. 安装vim [root@centos7 ~]# yum -y install vim-enhanced Loaded plugins: fastestmirror ba ...

  2. centos7系列-给普通用户sudo权限

    对于linux用户来讲,普通用户的权限是有一定限制的,所以在有些操作的时候,是需要sudo权限的,那么如何在linux下赋予普通用户sudo权限呢?此处将讲解一下方法. 在login我们的系统后,如果 ...

  3. CentOS7 系统服务器初始化配置、安全加固、内核升级优化常用软件安装的Shell脚本分享

    转载自:https://www.bilibili.com/read/cv13875630?spm_id_from=333.999.0.0 描述: 适用于企业内部 CentOS7 系列操作服务器初始化. ...

  4. cobbler部署centos6与centos7系列

    cobbler部署centos6与centos7系列 转载自:http://www.jianshu.com/p/a4bed77bf40d 版权声明:完全抄自 http://www.jianshu.co ...

  5. 转载:Centos7 从零编译配置Memcached

    序言 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度. Memca ...

  6. [原创]Centos7 从零编译配置Memcached

    序言 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度. Memca ...

  7. centos7+redis+php环境配置

    centos7+redis+php环境配置 下载redis(更多版本可到redis官网进行查找) wget http://download.redis.io/releases/redis-3.0.7. ...

  8. CentOS7下Firewall防火墙配置用法详解

    官方文档地址: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide ...

  9. Linux用户配置sudo权限

    Linux用户配置sudo权限 创建sudo权限用户 #useradd supope #passwd supope #visudo #supope         ALL=(ALL)       AL ...

随机推荐

  1. WPF快速实现XML可视化编辑工具

    虽然最近业余时间主要都放在研究AngularJS上了,不过由于正好要帮朋友做一个生成XML的小工具,顺便又温顾了一下WPF.虽然这个时代相对于Web应用和移动App,Windows应用程序是越来越少了 ...

  2. vue 中使用 screenfull.js 全屏插件

    参考网址: https://blog.csdn.net/houyibing930920/article/details/89214200 https://www.jianshu.com/p/cfbb1 ...

  3. 科学经得起实践检验-python3.6通过决策树实战精准准确预测今日大盘走势(含代码)

    科学经得起实践检验-python3.6通过决策树实战精准准确预测今日大盘走势(含代码) 春有百花秋有月,夏有凉风冬有雪: 若无闲事挂心头,便是人间好时节. --宋.无门慧开 不废话了,以下训练模型数据 ...

  4. (转)MySQL慢查询日志总结

    慢查询日志概念 原文:http://www.cnblogs.com/kerrycode/p/5593204.html MySQL的慢查询日志是MySQL提供的一种日志记录,它用来记录在MySQL中响应 ...

  5. 使用spring EL表达式+自定义切面封装缓存模块

    需求是这样的,业务代码需要使用到缓存功能以减少数据库压力,使用redis来实现,并且需要生成缓存的key由方法的传参拼接而成(貌似也只能这样才能保证同样的select查询可以使用缓存),简单的方式就是 ...

  6. Pipenv——最好用的python虚拟环境和包管理工具

    pipenv 是Kenneth Reitz大神的作品,能够有效管理Python多个环境,各种包.过去我们一般用virtualenv搭建虚拟环境,管理python版本,但是跨平台的使用不太一致,且有时候 ...

  7. 【.Net】水晶报表CrystalReport粗浅入门

    VB6代码大概是这样的: crystalreport1.Connect:='dsn=xxx;uid=yyy;pwd=zzz;dsq=aaa'; crystalreport1.DiscardSavedD ...

  8. sockets+proxychains代理,使内网服务器可以访问外网

    Socks5+proxychains做正向代理 1.         应用场景: 有一台能上外网的机子,内网机子都不能连外网,需求是内网机子程序需要访问外网,做正向代理. 2.         软件 ...

  9. pageParam要求传个JSON对象的方法

    pageParam要求传个JSON对象,使用方式:api.openWin({name: 'page1',url: 'page1.html',pageParam: {x: '1000',y: '2000 ...

  10. jQuery通过input标签的name获取值

    jquery根据name属性查找 $("div[id]") 选择所有含有id属性的div元素 $("input[name='keleyicom']") 选择所有 ...