linux - 如何修改sudoers?
PHPz
PHPz 2017-04-17 17:07:21
0
5
797

centos6.5 新建了一个用户,希望给他root权限,网上说,编辑/etc/sudoers中的

## Allow root to run any commands anywhere
root    ALL=(ALL)     ALL

在后面添加
tommy ALL=(ALL) ALL就好了。

但是我找不到这段话,这段话在哪里?
这是我的sudoers

[root@localhost ~]# vi /etc/sudoers

## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.

## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias     FILESERVERS = fs1, fs2
# Host_Alias     MAILSERVERS = smtp, smtp2

## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem


## Command Aliases
"/etc/sudoers" [readonly] 111L, 3729C
PHPz
PHPz

学习是最好的投资!

reply all(5)
小葫芦

After observation, there is a biggest problem with your simple approach: after you open the file with vim, the pages are not turned.

In addition, you are currently in read-only status and cannot modify the file. Both crimes are punishable, please use visudo.

Peter_Zhu

Don’t listen to nonsense on the Internet. That sentence will take effect wherever you put it. If you don't have root, it won't work, and there won't be any problem.

Go and learn what those words sudoers mean, don’t just copy them from the messy websites from Baidu. Don’t forget the example Wei Zexi set for us at the cost of his life.

Update:

@Fu Yijun makes sense: try turning the page!

If you don’t know how to use vim/vi, you can try the simpler nano. Usage:

export EDITOR=nano
visudo
伊谢尔伦

@Evian makes sense.

The correct way is to use visudo命令,而不是修改/etc/sudoersfiles.

大家讲道理

tommy ALL=(ALL) NOPASSWD: ALL

左手右手慢动作

Red Hat systems have an administrator group wheel by default. It is generally recommended to add the sudo user to this group.
After logging in as the root user, use the visudo command to open the sudoer file.
Found

# %wheel        ALL=(ALL)       ALL

Remove the pound sign in front and it becomes

%wheel        ALL=(ALL)       ALL

Then use

 usermod -aG wheel 用户名

Add user to wheel group.
This is the recommended way.
With manual Configuring root access

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!