Linux权限管理(4)sudo权限

本文详细介绍了Linux系统中sudo权限的配置、命令使用及其应用。内容涵盖为用户和用户组配置sudo权限的注意事项,如谨慎授权,具体设置等。此外,还解析了sudo命令的不同用法,如以root身份执行命令、切换到root用户和shell,以及如何授权普通用户重启服务器和添加其他用户,同时强调了权限安全的重要性。
摘要由CSDN通过智能技术生成
学习 sudo 权限前,先了解一下当用户第一次使用sudo权限时CentOS的系统提示
我们信任您已经从系统管理员那里了解了日常注意事项。
总结起来无外乎这三点:
#1) 尊重别人的隐私。
#2) 输入前要先考虑(后果和风险)。
#3) 权力越大,责任越大。

sudo权限的作用是:使普通用户可以临时以 root 用户的身份和权限执行系统命令

sudo权限的操作对象是系统命令

一、sudo权限的配置

1. 编辑 sudo权限 命令

visudo
visudo 命令实际修改的是 /etc/sudoers 文件

2. /etc/sudoers 配置文件

[root/etc]# cat /etc/sudoers

... 省略部分内容 ...

## Allow root to run any commands anywhere
## 允许root在任何地方运行任何命令
root    ALL=(ALL)       ALL

## Allows members of the 'sys' group to run networking, software, service management apps and more.
## 允许“sys”用户组的成员运行 网络、软件、服务管理应用等命令。
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
## 允许“wheel”用户组的成员运行所有命令
%wheel  ALL=(ALL)       ALL

## Allows people in group wheel to run all commands without a password
## 允许“wheel”用户组的成员运行所有命令,且运行时不需要输入密码
# %wheel        ALL=(ALL)       NOPASSWD: ALL

## Allows members of the users group to mount and unmount the cdrom as root
## 允许“users”组的成员运行 挂载、卸载光盘的命令
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
## 允许“users”组的成员在本机运行 /sbin/shutdown -h now 命令
# %users  localhost=/sbin/shutdown -h now

## Read drop-in files from /etc/s
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值