8.1作业

创建用户gentoo,附加组为bin和root,默认shell为/bin/csh,注释信息为“Gentoo Distribution”

[root@localhost wang]# useradd -G bin,root -s /bin/csh -c "Gentoo distribution" gentoo
[root@localhost wang]# getent passwd gentoo
gentoo:x:2004:2004:Gentoo distribution:/home/gentoo:/bin/csh

创建下面的用户、组和组成员关系

名字为admins的组

用户natasha,使用admins 作为附属组

用户harry,也使用admins作为附属组

用户sarah,不可交互登录系统,且不是admins的成员

natasha,harry,sarah密码都是centos

[root@localhost wang]# groupadd admins
[root@localhost wang]# useradd -G admins natasha
[root@localhost wang]# useradd -G admins harry
[root@localhost wang]# useradd -s /sbin/nologin sarah
[root@localhost wang]# echo "centos" | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root@localhost wang]# echo "centos" | passwd --stdin harry 
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root@localhost wang]# echo "centos" | passwd --stdin sarah 
Changing password for user sarah.
passwd: all authentication tokens updated successfully.
[root@localhost wang]#

一次创建多个用户并配置密码

[root@localhost ~]# vi user.txt

linux1:x:2001:2001::/home/linux1:/bin/bash
linux2:x:2002:2002::/home/linux2:/bin/bash
linux3:x:2003:2003::/home/linux3:/bin/bash
~                                                                                     
~                                                                                     
~
[root@localhost ~]# newusers user.txt
[root@localhost ~]# ls /home
gentoo  harry  linux1  linux2  linux3  mageedu  natasha  sarah
[root@localhost ~]# cat /etc/passwd    
...
...
...  
linux1:x:2001:2001::/home/linux1:/bin/bash
linux2:x:2002:2002::/home/linux2:/bin/bash
linux3:x:2003:2003::/home/linux3:/bin/bash
[root@localhost ~]# vi passwd.txt

linxu1:123456
linux2:234567
linux3:345678
~                                                                                     
~                                                                                     
~                                                                                     
~                                                                                     
[root@localhost ~]# cat passwd.txt | chpasswd  
[root@localhost ~]# cp /etc/skel/.[^.]* /home/linux1

创建testuser  uid:1234  主组:bin 辅助组:root,ftp shell:/bin/csh home:/testdir/testuser

[root@localhost /]# useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser -m testuser
[root@localhost /]# id  testuser
uid=1234(testuser) gid=1(bin) groups=1(bin),0(root),50(ftp)
[root@localhost /]# groups testuser 
testuser : bin root ftp

修改testuser uid:4321 主组:root 辅助组:nobody loginname:test home:/home/test 家数据迁移

[root@localhost /]# usermod -u 4321 -g root -G nobody -l test -d /home/test -m testuser 
[root@localhost /]# id test
uid=4321(test) gid=0(root) groups=0(root),99(nobody)
[root@localhost /]# groups test 
test : root nobody

批量创建帐号 user1-user10 uid:3000-3009 shell:/bin/csh home:testdir/user 密码:user1pass

[root@localhost /]# vi user.txt

user1:x:3000:3000::/testdir/user1:/bin/csh
user2:x:3001:3001::/testdir/user2:/bin/csh
user3:x:3002:3002::/testdir/user3:/bin/csh
user4:x:3003:3003::/testdir/user4:/bin/csh
user5:x:3004:3004::/testdir/user5:/bin/csh
user6:x:3005:3005::/testdir/user6:/bin/csh
user7:x:3006:3006::/testdir/user7:/bin/csh
user8:x:3007:3007::/testdir/user8:/bin/csh
user9:x:3008:3008::/testdir/user9:/bin/csh
user10:x:3009:3009::/testdir/user10:/bin/csh
~                                                                                     
~                                                                                     
[root@localhost /]# newusers user.txt  
[root@localhost /]# vi passwd.txt

user1:user1pass
user2:user2pass
user3:user3pass
user4:user4pass
user5:user5pass
user6:user6pass
user7:user7pass
user8:user8pass
user9:user9pass
user10:user10pass
~                                                                                     
~                   
[root@localhost /]# cat passwd.txt | chpasswd   
[root@localhost ~]# cp /etc/skel/.[^.]* /testdir/user1
cp: omitting directory ‘/etc/skel/.mozilla’
[root@localhost ~]# su - user1
[user1@localhost ~]$ exit
logout
[root@localhost ~]#

原创文章,作者:DYW,如若转载,请注明出处:http://www.178linux.com/27361

(0)
DYWDYW
上一篇 2016-08-02
下一篇 2016-08-02

相关推荐

  • 将两个局域网用openvpn连接起来

    考虑到我们做集群的时候需要用到可能有20台机器,可能我的要求跟别人的不一样的,我需要做20台左右的集群,不仅仅是会,而且需要非常熟练的搭建,最后通过脚步一键自动化部署安装。 目前我有两台电脑,一台可以运行7台,另一台可以运行12台左右,刚好可以满足的我的要求,但是我两台电脑都是设置的nat模式的网络,为什么我非要配置nat模式呢,根据集群架构思想,为了保证架…

    Linux干货 2017-05-01
  • Linux基础学习总结(六)

    一、完成如下练习 1、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#; vim: cp /etc/rc.sysinit /tmp/rc.sysinitvim/tmp/rc.sysinit:%s@^[[:space:]]\+@#&@g sed: sed “s/…

    Linux干货 2016-10-30
  • 进程与计划任务

    PID 进程号,用来标记各个进程;CentOS6中起始的第一个进程为init7中为systemd 进程优先级: 系统优先级:数字越小,优先级越高 0-139(4,5中) 各有140个运行队列和过期队列 0-98,99(6中) 实时优先级:99-0:值越大优先级越高 nice值:-20到19,对应系统优先级100-139或99 进程状态: 运行:running…

    2017-05-14
  • linux文件的时间

    1,linux文件有哪些时间属性     access time:atime 访问时间:即查看访问文件的时间     modify time:mtime 修改时间:修改文件内容的时间     change time:ctime 改变时间:修…

    Linux干货 2016-06-09
  • 用户、组的创建和管理

    用户的创建 useradd usermod userdel useradd:创建用户 create a new user or update default new user information     useradd [options]… LOGIN     &…

    Linux干货 2016-08-03
  • 排错

    把/etc/inittab  模式改为6模式 怎么修复 1 先把 vim /etc/inittab 打开 2 把/etc/inittab 模式改为6 3 reboot 4 在倒计时完之前按任意键 5按A进入 6 在quiet  命令后面写入 3  模式 重启 7把 vim /etc/inittab 打开 8 把/etc…

    Linux干货 2017-05-15