首页 > 系统服务 > 详细

LINUX用户和组小练习

时间:2014-05-27 03:36:19      阅读:575      评论:0      收藏:0      [点我收藏+]

1.创建一个用户mandriva,其ID号为2002,基本组为distro(组ID为3003),附加组为linux

[root@localhost ~]# groupadd -g 3003 distro
[root@localhost ~]# tail -1 /etc/group
distro:x:3003:
[root@localhost ~]# groupadd linux
[root@localhost ~]# tail -1 /etc/group
linux:x:3004:
[root@localhost ~]# useradd -u 2002 -g distro -G linux mandriva
[root@localhost ~]# id mandriva
uid=2002(mandriva) gid=3003(distro) groups=3003(distro),3004(linux) context=root:system_r:unconfined_t:SystemLow-SystemHigh



2.创建一个用户fedora,其全名为Fedora Community,默认shell为tcsh

[root@localhost ~]# useradd -c "Fedora Commnuity" -s /bin/tcsh fedora
[root@localhost ~]# id fedora
uid=2003(fedora) gid=2003(fedora) groups=2003(fedora) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]# finger fedora
Login: fedora                   Name: Fedora Commnuity
Directory: /home/fedora                 Shell: /bin/tcsh
Never logged in.
No mail.
No Plan.
[root@localhost ~]#


3.修改mandriva的ID号为4004,基本组为linux,附加组为distro和fedora

[root@localhost ~]# usermod -u 4004 -g linux -G distro,fedora mandriva
[root@localhost ~]# id mandriva
uid=4004(mandriva) gid=3004(linux) groups=3004(linux),3003(distro),2003(fedora) context=root:system_r:unconfined_t:SystemLow-SystemHigh


4.给fedora加密码,并设定其密码最短使用期限为2天,最长为50天。

[root@localhost ~]# passwd fedora
Changing password for user fedora.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd -n 2 -x 50 fedora
Adjusting aging data for user fedora.
passwd: Success
[root@localhost ~]#


5.将mandriva的默认shell改为/bin/bash

[root@localhost ~]# usermod -s /bin/bash mandriva
[root@localhost ~]# id mandriva
uid=4004(mandriva) gid=3004(linux) groups=3004(linux),3003(distro),2003(fedora) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]# finger mandriva
Login: mandriva                 Name: (null)
Directory: /home/mandriva               Shell: /bin/bash
Never logged in.
No mail.
No Plan.
[root@localhost ~]#


6.添加系统用户hbase,且不允许其登陆系统。

[root@localhost ~]# useradd -r -s /bin/nologin hbase
[root@localhost ~]# tail -1 /etc/passwd
hbase:x:102:103::/home/hbase:/bin/nologin
[root@localhost ~]# su - hbase
su: warning: cannot change directory to /home/hbase: No such file or directory
su: /bin/nologin: No such file or directory
[root@localhost ~]#













本文出自 “我想超越自我” 博客,请务必保留此出处http://zhangfengzhe.blog.51cto.com/8855103/1412871

LINUX用户和组小练习,布布扣,bubuko.com

LINUX用户和组小练习

原文:http://zhangfengzhe.blog.51cto.com/8855103/1412871

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!