首页 > 代码库 > LINUX用户和组小练习
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。