服务器系列之组和用户和权限的管理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#添加组testg
groupadd testg
 
#添加用户test
useradd -g testg -c "A test user, test@gmail.com" test
echo "testpsswd" | passwd --stdin test
 
#配置sudoers
#把用户test添加到admin组中
usemod -G admin test
#修改/etc/sudoers,使admin组享有管理员权限
cp /etc/sudoers /etc/sudoers_$(date +%Y%m%d).bak
vim /etc/sudoers
#添加如下两行
# Allow members of group admin to execute any command
%admin ALL=(ALL) ALL
 
#修改权限
#更改所有者
chown USER FILE/DIR
#更改所属组
chgrp GROUP FILE/DIR
#同时修改所有者和所属组
chown USER:GROUP FILE/DIR
#修改权限
chmod 755 FILE/DIR
#详细的使用方法请man,如:man chown