日期:2014-05-16  浏览次数:20708 次

Linux下用户/组的管理
对于Linux下用户/组的管理机制,以前有个大概的认识,没有进行相关方面的实际操作。今天怀疑一个执行命令的问题是因为sudo产生的,就对这方面的知识进行了学习。

Linux 用户(user)和用户组(group)管理概述
http://fedora.linuxsir.org/main/?q=node/91

useradd和groupadd的简单实例
# groupadd -g 102 test
# useradd -u 1003 -g 102 -d /home/test1 -s /bin/bash \
-c "Test 1" -m -k /etc/skel test1


给test1用户sudo权限
# chmod u+w /etc/sudoers
# vi /etc/sudoers
## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)   ALL
test1   ALL=(ALL)   ALL         # 执行sudo命令时需要输入密码
# test1   ALL=NOPASSWD:   ALL   # 不需要输入密码
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL