请总结描述用户和组管理类命令的使用方法并完成以下练习

(1)、创建组distro,其GID为2019

[root@centos7 ~]#groupadd -g 2019 distro
[root@centos7 ~]#cat /etc/group|tail -1
distro:x:2019:

(2)、创建用户mandriva, 其ID号为1005;基本组为distro

[root@centos7 ~]#useradd -u 1005 -g distro mandriva
[root@centos7 ~]#id mandriva
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)

(3)、创建用户mageia,其ID号为1100,家目录为/home/linux

[root@centos7 ~]#useradd -u 1100 -d /home/linux mageia
[root@centos7 ~]#id mageia
uid=1100(mageia) gid=1100(mageia) groups=1100(mageia)
[root@centos7 ~]#ls /home/
linux  mandriva  nbdj  nbdj2  test  test1

(4)、给用户mageia添加密码,密码为mageedu,并设置用户密码7天后过期

[root@centos7 ~]#echo "mageedu"|passwd --stdin mageia
Changing password for user mageia.
passwd: all authentication tokens updated successfully.
[root@centos7 ~]#passwd -x 7 mageia
Adjusting aging data for user mageia.
passwd: Success

(5)、删除mandriva,但保留其家目录

[root@centos7 ~]#userdel mandriva
[root@centos7 ~]#ls /home/
linux  mandriva  nbdj  nbdj2  test  test1

(6)、创建用户slackware,其ID号为2002,基本组为distro,附加组peguin

[root@centos7 ~]#groupadd peguin
[root@centos7 ~]#useradd -u 2002 -g distro -G peguin slackware
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)

(7)、修改slackware的默认shell为/bin/tcsh

[root@centos7 ~]#usermod -s /bin/tcsh slackware
[root@centos7 ~]#cat /etc/passwd|tail -1
slackware:x:2002:2019::/home/slackware:/bin/tcsh

(8)、为用户slackware新增附加组admins

[root@centos7 ~]#groupadd admins
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
[root@centos7 ~]#usermod -aG admins slackware
[root@centos7 ~]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值