需求描述:
建立用户目录
- 创建目录/tech/benet和/tech/accp,分别用于存放各项目组中用户账户的宿主文件夹
添加组账号
- 为两个项目组添加组账号benet、accp,GID号分别设置为2001、2002。
- 为技术部添加组账号tech,GID号设置为300
添加用户账号
- benet组包括三个用户,分别为kylin、tsengia、obama,宿主目录均为使用/tech/benet/目录中与账号同名的文件夹。其中kylin用户账号设为2018年12月31日后失效
- accp组包括两个用户,分别是handy、cucci,宿主目录均使用/tech/accp/目录中与账号同名的文件夹。其中cucci用户的登陆Shell设为/bin/sh
上述所有的用户账号均要求加入tech组内
在测试阶段,仅为kylin、tsengia、handy这三个用户账号设置初始密码“123456”,其他用户暂时不设置密码。
设置目录权限及归属。
- 将/tech目录的属组设置为tech,去除其他用户的所有权限
- 将/tech/benet目录的属组设置为benet,去除其他用户的所有权限
- 将/tech/accp目录的属组设置为accp,去除其他用户的所有权限
建立公共数据存储目录
- 创建/public目录,允许所有技术组内的用户读取、写入、执行文件,非技术组的用户禁止访问此目录
建立用户目录
- 创建目录/tech/benet和/tech/accp,分别用于存放各项目组中用户账户的宿主文件夹
[root@localhost ~]# mkdir -p /tech/benet /tech/accp
[root@localhost ~]# ls /tech
accp benet
添加组账号
- 为两个项目组添加组账号benet、accp,GID号分别设置为2001、2002。
[root@localhost ~]# groupadd -g 2001 benet
[root@localhost ~]# groupadd -g 2002 accp
- 为技术部添加组账号tech,GID号设置为300
[root@localhost ~]# groupadd -g 300 tech
添加用户账号
- benet组包括三个用户,分别为kylin、tsengia、obama,宿主目录均为使用/tech/benet/目录中与账号同名的文件夹。其中kylin用户账号设为2018年12月31日后失效
[root@localhost ~]# gpasswd -a kylin benet
正在将用户“kylin”加入到“benet”组中
[root@localhost ~]# gpasswd -a tsengia benet
正在将用户“tsengia”加入到“benet”组中
[root@localhost ~]# gpasswd -a obama benet
正在将用户“obama”加入到“benet”组中
[root@localhost ~]# useradd -d /tech/benet/kylin -e 2018-12-31 kylin
[root@localhost ~]# useradd -d /tech/benet/tsengia tsengia
[root@localhost ~]# useradd -d /tech/benet/obama obama
- accp组包括两个用户,分别是handy、cucci,宿主目录均使用/tech/accp/目录中与账号同名的文件夹。其中cucci用户的登陆Shell设为/bin/sh
[root@localhost ~]# gpasswd -a handy accp
正在将用户“handy”加入到“accp”组中
[root@localhost ~]# gpasswd -a cucci accp
正在将用户“cucci”加入到“accp”组中
[root@localhost ~]# useradd -d /tech/accp/handy handy
[root@localhost ~]# useradd -d /tech/accp/cucci -s /bin/sh cucci
在测试阶段,仅为kylin、tsengia、handy这三个用户账号设置初始密码“123456”,其他用户暂时不设置密码。
[root@localhost ~]# passwd kylin
更改用户 kylin 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]# passwd tsengia
更改用户 tsengia 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost ~]# passwd handy
更改用户 handy 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
设置目录权限及归属。
- 将/tech目录的属组设置为tech,去除其他用户的所有权限
[root@localhost ~]# ll -d /tech
drwxr-xr-x 4 root root 31 7月 1 15:43 /tech
[root@localhost ~]# chown :tech /tech
[root@localhost ~]# ll -d /tech
drwxr-xr-x 4 root tech 31 7月 1 15:43 /tech
//去除其他用户的所有权限
[root@localhost ~]# chmod o-rwx /tech
[root@localhost ~]# ll -d /tech
drwxr-x--- 4 root tech 31 7月 1 15:43 /tech
- 将/tech/benet目录的属组设置为benet,去除其他用户的所有权限
[root@localhost ~]# ll -d /tech/benet
drwxr-xr-x 5 root root 47 7月 1 15:56 /tech/benet
[root@localhost ~]# chown :benet /tech/benet
[root@localhost ~]# ll -d /tech/benet
drwxr-xr-x 5 root benet 47 7月 1 15:56 /tech/benet
//去除其他用户的所有权限
[root@localhost ~]# chmod o-rwx /tech/benet
[root@localhost ~]# ll -d /tech/benet
drwxr-x--- 5 root benet 47 7月 1 15:56 /tech/benet
- 将/tech/accp目录的属组设置为accp,去除其他用户的所有权限
[root@localhost ~]# ll -d /tech/accp
drwxr-xr-x 4 root root 32 7月 1 15:57 /tech/accp
[root@localhost ~]# chown :accp /tech/accp
[root@localhost ~]# ll -d /tech/accp
drwxr-xr-x 4 root accp 32 7月 1 15:57 /tech/accp
[root@localhost ~]# chmod o-rwx /tech/accp
[root@localhost ~]# ll -d /tech/accp
drwxr-x--- 4 root accp 32 7月 1 15:57 /tech/accp
建立公共数据存储目录
- 创建/public目录,允许所有技术组内的用户读取、写入、执行文件,非技术组的用户禁止访问此目录
[root@localhost ~]# mkdir /public
[root@localhost ~]# ll -d /public
drwxr-xr-x 2 root root 6 7月 1 16:14 /public
[root@localhost ~]# chown :tech /public
[root@localhost ~]# ll -d /public
drwxr-xr-x 2 root tech 6 7月 1 16:14 /public
[root@localhost ~]# chmod 070 /public
[root@localhost ~]# ll -d /public
d---rwx--- 2 root tech 6 7月 1 16:14 /public