标签:linux 用户 组
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 用户 组
原文地址:http://zhangfengzhe.blog.51cto.com/8855103/1412871