博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sudoers配置文件
阅读量:6938 次
发布时间:2019-06-27

本文共 1408 字,大约阅读时间需要 4 分钟。

hot3.png

sudo是linux下常用的允许普通用户使用超级用户权限的工具。
它的主要配置文件是sudoers,linux下通常在/etc目录下,如果是solaris,缺省不装sudo的,编译安装后通常在安装目录的 etc目录下,不过不管sudoers文件在哪儿,sudo都提供了一个编辑该文件的命令:visudo来对该文件进行修改。强烈推荐使用该命令修改 sudoers,因为它会帮你校验文件配置是否正确,如果不正确,在保存退出时就会提示你哪段配置出错的。 【注:如果直接使用vi命令编辑,会提示文件写权限不足。应该该文件权限为440。】
言归正传,下面介绍如何配置sudoers
首先写sudoers的缺省配置:
#############################################################
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
# Defaults specification
# User privilege specification
root    ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
# Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL
# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now
##################################################################
1. 最简单的配置,让普通用户support具有root的所有权限
执行visudo之后,可以看见缺省只有一条配置:
root    ALL=(ALL) ALL
那么你就在下边再加一条配置:
support ALL=(ALL) ALL
这样,普通用户support就能够执行root权限的所有命令
以support用户登录之后,执行:
sudo su -

然后输入support用户自己的密码,就可以切换成root用户了

【注:如果不配置,那么在该账号下使用sudo就会提示如下错误 "xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权限使用sudo,我们只要修改一下/etc/sudoers文件就行了。】

转载于:https://my.oschina.net/frankwu/blog/80025

你可能感兴趣的文章
Codeforces Round #531 (Div. 3)题解
查看>>
bzoj 2732 [HNOI2012]射箭 半平面交(刘汝佳版不超时) + 整型二分处理
查看>>
servlet之@PostConstruct,@PreDestroy
查看>>
POJ-1925 Spiderman 动态规划
查看>>
winSocket编程(一)WSAStartup
查看>>
grid的简单使用
查看>>
第一天作业
查看>>
MySQL常见面试题
查看>>
简易涂鸦板
查看>>
jquerymobile总结
查看>>
Linux常用命令
查看>>
跟一个久未见面的同学聊天
查看>>
华为自带浏览器兼容性总结其一
查看>>
Linux下的gcc,cc,g++,CC的区别
查看>>
Realm Objective-C 数据库操作
查看>>
asp.net 检测是否是有效连接地址
查看>>
html清屏 meta http-equiv="refresh" content="3">
查看>>
Java
查看>>
hdu 2161(Primes)
查看>>
js 进阶 10 js选择器大全
查看>>