CentOS7系列--1.6CentOS7配置sudo
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的更多相关文章
- CentOS7系列--1.5CentOS7配置vim
CentOS7配置vim 1. 安装vim [root@centos7 ~]# yum -y install vim-enhanced Loaded plugins: fastestmirror ba ...
- centos7系列-给普通用户sudo权限
对于linux用户来讲,普通用户的权限是有一定限制的,所以在有些操作的时候,是需要sudo权限的,那么如何在linux下赋予普通用户sudo权限呢?此处将讲解一下方法. 在login我们的系统后,如果 ...
- CentOS7 系统服务器初始化配置、安全加固、内核升级优化常用软件安装的Shell脚本分享
转载自:https://www.bilibili.com/read/cv13875630?spm_id_from=333.999.0.0 描述: 适用于企业内部 CentOS7 系列操作服务器初始化. ...
- cobbler部署centos6与centos7系列
cobbler部署centos6与centos7系列 转载自:http://www.jianshu.com/p/a4bed77bf40d 版权声明:完全抄自 http://www.jianshu.co ...
- 转载:Centos7 从零编译配置Memcached
序言 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度. Memca ...
- [原创]Centos7 从零编译配置Memcached
序言 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度. Memca ...
- centos7+redis+php环境配置
centos7+redis+php环境配置 下载redis(更多版本可到redis官网进行查找) wget http://download.redis.io/releases/redis-3.0.7. ...
- CentOS7下Firewall防火墙配置用法详解
官方文档地址: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide ...
- Linux用户配置sudo权限
Linux用户配置sudo权限 创建sudo权限用户 #useradd supope #passwd supope #visudo #supope ALL=(ALL) AL ...
随机推荐
- Python单行注释与多行注释
>>> print "hello,world"hello,world>>> 2+24#单行注释 """每行代码的后 ...
- RxJava/RxAndroid 使用实例实践
原文地址 RxAndroid Tutorial响应式编程(Reactive programming)不是一种API,而是一种新的非常有用的范式,而RxJava就是一套基于此思想的框架,在Android ...
- 【Express系列】第1篇——项目创建
安装 node 和 Express 4 node官网:http://nodejs.org/ Express Github:https://github.com/expressjs/express ...
- WPF中常用的Window事件
官方链接:https://msdn.microsoft.com/en-us/library/system.windows.window.statechanged(v=vs.110).aspx 1. A ...
- WPF设置控件获得焦点FocusManager
简单用法如下: 在父类容器中通过附加属性FocusManager.FocusedElement来绑定需要强制获得焦点的控件,用法如下: <Grid FocusManager.FocusedE ...
- Linux用户信息查询
1 查询目前已登录的用户信息w 或者 who [@bjzw_11_210 ~]# w :: up days, :, users, load average: 0.03, 0.04, 0.00 USER ...
- springMVC实现json
很多时候前端都需要调用后台服务实现交互功能,常见的数据交换格式多是JSON或XML,这里主要讲解Spring MVC为前端提供JSON格式的数据并实现与前台交互. 一.概要 JSON(JavaScri ...
- docker改国内官方镜像
如何使用官方镜像 Docker 中国官方镜像加速可通过 registry.docker-cn.com 访问.目前该镜像库只包含流行的公有镜像,而私有镜像仍需要从美国镜像库中拉取. 您可以使用以下命令直 ...
- Cmake编写JNI
调用两个库 CMakeLists.txt //把那种大段的注释去掉了 cmake_minimum_required(VERSION ) add_library( # Sets the name of ...
- Golang xorm工具,根据数据库自动生成 go 代码
使用 golang 操作数据库的同学都会遇到一个问题 —— 根据数据表结构创建对应的 struct 模型.因为 golang 的使用首字母控制可见范围,我们经常要设计 struct 字段名和数据库字段 ...