账号和权限

账号和权限管理

实验:用户和文件权限管理

1、建立用户目录

创建目录/tech/benet和/tech/accp,分别用于存放各项目组中用户账号的宿主文件夹。
[root@centos06 ~]# mkdir -p /tech/benet
[root@centos06 ~]# mkdir -p /tech/acc

2、添加组账号

1)为两个项目组添加组账号benet、accp,GID号分别设置为2001、2002。

[root@centos06 ~]# groupadd -g 2001 benet
[root@centos06 ~]# groupadd -g 2002 accp

[root@centos06 ~]# tail -2 /etc/group
在这里插入图片描述
2)为技术部添加组账号tech、GID号设置为300。
[root@centos06 ~]# groupadd -g 300 tech
[root@centos06 ~]# tail -1 /etc/group
在这里插入图片描述

3、添加用户账号

1)benet组包括三个用户,分别为kylin、tsengia、obama,宿主目录均使用/tech/benet目录中与账号同名的文件夹。其中kylin用户设为2019年12月31日后失效。
[root@centos06 ~]# useradd kylin
[root@centos06 ~]# useradd tsengia
[root@centos06 ~]# useradd obama

[root@centos06 ~]# tail -3 /etc/passwd

[root@centos06 ~]# mv /home/kylin/ /tech/benet/kylin
[root@centos06 ~]# usermod -d /tech/benet/kylin/ kylin

[root@centos06 ~]# mv /home/obama/ /tech/benet/obama
[root@centos06 ~]# usermod -d /tech/benet/obama/ obama

[root@centos06 ~]# mv /home/tsengia/ /tech/benet/tsengia
[root@centos06~]#usermod -d /tech/benet/tsengia/ tsengia
[root@centos06 ~]# tail -2 /etc/passwd

[root@centos06 ~]# usermod -e 2019-12-31 kylin

[root@centos06 ~]# tail -2 /etc/shadow
2)accp组包括两个用户,分别为handy、cucci,宿主目录均使用/tech/accp/目录中与账号同名的文件夹。其中cucci用户的登录Shell设为/bin/sh
[root@centos06 ~]# useradd handy
[root@centos06 ~]# useradd cucci

[root@centos06 ~]# mv /home/handy/ /tech/accp/handy
[root@centos06 ~]# usermod -d /tech/accp/handy/ handy
[root@centos06 ~]# mv /home/cucci/ /tech/accp/cucci
[root@centos06 ~]# usermod -d /tech/accp/cucci/ cucci

[root@centos06 ~]# usermod -s /bin/sh cucci

3)上述所有的用户账户均要求加入tech组内
[root@centos06 ~]# gpasswd -M “kylin,tsengia,handy” tech

[root@centos06 ~]# tail -10 /etc/group
4)在测试阶段,仅为kylin、tsengia、handy这三个用户账号设置初始密码“123456”,其他用户暂时先不设置密码。
[root@centos06 ~]# passwd tsengia
[root@centos06 ~]# passwd kylin
[root@centos06 ~]# passwd handy

[root@centos06 ~]# tail /etc/shadow

5、设置目录权限及归属。

1)将/tech目录的属组设置为tech,去除其他用户的所有权限。
[root@centos06 ~]# chown :tech /tech
[root@centos06 ~]# ls -ld /tech/
在这里插入图片描述
2)将/tech/benet目录的属组设置为benet,去除其他用户的所有权限。
[root@centos06 ~]# chown :benet /tech/benet/
[root@centos06 ~]# ls -ld /tech/benet/
[root@centos06 ~]# chmod o-rx /tech/benet/

3)将/tech/accp目录的属组设置为accp,去除其他用户的所有权限。
[root@centos06 ~]# chown :accp /tech/accp/
[root@centos06 ~]# chmod o-rx /tech/accp/
[root@centos06 ~]# ls -ld /tech/accp/
在这里插入图片描述

6、建立公共数据存储目录

1)创建/public目录,允许所有技术组内的用户读取、写入、执行文件,非技术组的用户禁止访问此目录。
[root@centos06 ~]# mkdir /public
[root@centos06 ~]# chown :tech /public/
2)设置访问权限
[root@centos06 ~]# chmod 770 /public/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值