当前位置:网站首页>sudo 权限控制,简易
sudo 权限控制,简易
2022-08-04 01:54:00 【qq_38781075】
修改sudo权限的文件在下面这里,记得给予写权限
chmod +w /etc/sudoers
vim /etc/sudoers
我设置了一组命令叫做 USERCMD (名字随便起),只能用sudo执行cp命令,不能用sudo执行kill命令,并且免密使用sudo (下面示例是test用户),加 ! 表示不能执行哪些命令,见下面框框里
其实只要你不写 /usr/bin/ 这样的命令给用户使用(因为代表 /usr/bin/ 下所有命令),不加 ! 也没事,另外,sudoers 是从后往前进行检测的(后面的优先级判定高),也就是 ! 这种命令要放后面
还有就是支持正则 比如 : /usr/bin/cp ~/* /home ,这样的命令,但是不能写 " ,只能斜杠转义空格,见
linux - How to let the user execute a command containing quotes in sudoers? - Server Fault
Cmnd_Alias 相当于是设置命令组,可以设置多个,用的时候可以用逗号分隔
Cmnd_Alias USERCMD=/usr/bin/cp,!/usr/bin/kill
# Cmnd_Alias TESTCMD=/usr/bin/cp,!/usr/bin/kill
test ALL=(ALL) NOPASSWD: USERCMD
# test ALL=(ALL) NOPASSWD: USERCMD,TESTCMD
如果想直接给予root同等权限,建议
test ALL=(ALL) NOPASSWD: ALL
详细还是参考
边栏推荐
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- MallBook联合人民交通出版社,推动驾培领域新发展,开启驾培智慧交易新生态
- Apache DolphinScheduler actual combat task scheduling platform - a new generation of distributed workflow
- 什么是SVN(Subversion)?
- 关联接口测试
- priority_queue元素为指针时,重载运算符失效
- esp32 releases robot battery voltage to ros2 (micro-ros+CoCube)
- nodejs+express实现数据库mysql的访问,并展示数据到页面上
- 天地图坐标系转高德坐标系 WGS84转GCJ02
- KunlunBase 1.0 is released!
猜你喜欢
随机推荐
IDEA02:配置SQL Server2019数据库
Quickly build a website with static files
内网穿透-应用
How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
halcon自定义函数基本操作
Intranet penetration - application
Multithreading JUC Learning Chapter 1 Steps to Create Multithreading
Example: 036 is a prime number
阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践
Parquet encoding
实例041:类的方法与变量
Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain
实例038:矩阵对角线之和
MongoDB数据接入实践
简单的线性表的顺序表示实现,以及线性表的链式表示和实现、带头节点的单向链表,C语言简单实现一些基本功能
Summary of GNSS Articles
2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"
一个项目的整体测试流程有哪几个阶段?测试方法有哪些?
nodejs安装及环境配置
lombok注解@RequiredArgsConstructor的使用