运维管理服务器的时候,权限特别的重要。
我们在服务器上操作的要尽可能的把权限限制小来,所以能不用root就不用root,特殊的时候可以用sudo
来提高权限。
我们还可以通过编辑/etc/sudoers
来限制用户可以通过sudo执行的命令。提高了执行命令的权限,避免因为权限过大导致无可挽回的损失(毕竟su
的权限太可怕了)。
首先,使用root帐号,设置/etc/sudoers
可写
chmod u+w /etc/sudoers
在/etc/sudoers
文件中修改:
## Allows members of the users group to shutdown this system
# %users localhost=/sbin/shutdown -h now
test ALL=NOPASSWD:/bin/svn
这样名为test
的用户在执行sudo svn up等命令的时候,就可以免密码执行。