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. [原创] rtrim() 格式化中文问题

    先看以下代码 var_dump(rtrim("互联网产品.", ".")); 我们以为会得到结果 "互联网产品", 但实际上获得的是 &qu ...

  2. oauth2.0实现sso单点登录的方式和相关代码

    SSO介绍 什么是SSO 百科:SSO英文全称Single Sign On,单点登录.SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统.它包括可以将这次主要的登录映射到其他 ...

  3. 【Java并发编程】:并发新特性—Lock锁和条件变量

    简单使用Lock锁 Java5中引入了新的锁机制——Java.util.concurrent.locks中的显式的互斥锁:Lock接口,它提供了比synchronized更加广泛的锁定操作.Lock接 ...

  4. windows本地调试安装hadoop(idea) : ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path

    1,本地安装hadoop https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/ 下载hadoop对应版本 (我本意是想下载hadoop ...

  5. Eclipse-离线安装Memory Anlysis Tool

    Eclipse版本:Version: Mars.2 Release (4.5.2) 1.从官网下载MAT Memory Anlysis Tool http://www.eclipse.org/mat/ ...

  6. 【链表】Swap Nodes in Pairs(三指针)

    题目: Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1-> ...

  7. nginx添加多站点

    1.登陆服务器2.修改ngnix配置文件3.重启ngnix4.测试是否添加成功 修改/nginx/conf/nginx.confviminclude /alidata/server/nginx/con ...

  8. tensorflow 滑动平均使用和恢复

    https://www.cnblogs.com/hrlnw/p/8067214.html

  9. centos7防暴力破解五种方法

    什么是暴力破解,简单来说就是对一个服务器进行无数次尝试登陆,并用不同的密码进行登陆直到可以登陆成功.暴力破解的基本步骤可以分为以下几步: 1. 找到对应的linux服务器    Ip地址 2.扫描端口 ...

  10. [笔记] print函数进阶

      1.1print(values=None,sep='',end='\n',file=sys.stdout,flush=False) 参数: values:输出到控制台的string sep:设置输 ...