Linux 第五天: (08月01日) 练习和作业

Linux 第五天: (08月01日) 练习和作业

 

 

 

 

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

useradd -G bin,root -c "Gentoo Distribution" -s /bin/csh gentoo ; id gentoo

 

 

创建名为admins的组
用户natasha, 使用admins作为附属组
用户harry, 也是有admins作为附属组
用户sarah, 不可交互登录系统, 且不是admins成员
natasha, harry, sarah密码都是centos

 

groupadd admins
useradd -G admins natasha
useradd -G admins harry
useradd -s /sbin/nologin sarah
echo "centos" |passwd –stdin natasha
echo "centos" |passwd –stdin harry
echo "centos" |passwd –stdin sarah

 

 

 

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

 useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser

 

 

 

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

 usermod testuser -u 4321 -g root -G nobody -l test -dm /home/test

 

 

 

批量创建帐号 user1…user10
uid:3000-3009, shell:/bin/csh, home:/testdir/username, passwd:usernamepass
注意家目录相关设置,使用户正常登录

 

vi user.txt

 

user1:x:3000:3000::/home/testdir/user1/:/bin/csh
user2:x:3001:3001::/home/testdir/user2/:/bin/csh
user3:x:3002:3002::/home/testdir/user3/:/bin/csh
user4:x:3003:3003::/home/testdir/user4/:/bin/csh
user5:x:3004:3004::/home/testdir/user5/:/bin/csh
user6:x:3005:3005::/home/testdir/user6/:/bin/csh
user7:x:3006:3006::/home/testdir/user7/:/bin/csh
user8:x:3007:3007::/home/testdir/user8/:/bin/csh
user9:x:3008:3008::/home/testdir/user9/:/bin/csh
user10:x:3009:3009::/home/testdir/user10/:/bin/csh

 

newusers user.txt

 

vi pawd.txt

 

user1:user1pass
user2:user2pass
user3:user3pass
user4:user4pass
user5:user5pass
user6:user6pass
user7:user7pass
user8:user8pass
user9:user9pass
user10:user10pass

 

cat pawd.txt |chpasswd

 

cp -r /etc/skel/.[^.]* /testdir/user1
cp -r /etc/skel/.[^.]* /testdir/user2
cp -r /etc/skel/.[^.]* /testdir/user3
cp -r /etc/skel/.[^.]* /testdir/user4
cp -r /etc/skel/.[^.]* /testdir/user5
cp -r /etc/skel/.[^.]* /testdir/user6
cp -r /etc/skel/.[^.]* /testdir/user7
cp -r /etc/skel/.[^.]* /testdir/user8
cp -r /etc/skel/.[^.]* /testdir/user9
cp -r /etc/skel/.[^.]* /testdir/user10

 

 

 

 

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

(0)
dengjiandengjian
上一篇 2016-08-08 09:22
下一篇 2016-08-08 09:22

相关推荐

  • CentOS6系统启动流程分析

    Linux系统组成        从动态视角看:由内核+根文件系统组成        从静态视角看:由磁盘分区及相关文件组成 内核设计流派        单内核:所有内核功能集中于同一程序;   &n…

    Linux干货 2016-09-09
  • CentOS7的虚拟机安装

    刚学习linux下CentOS7的操作,熟悉一下CentOS7的安装,所以写一下CentOS7的安装教程,如果那里有写的不对的话希望得到指正。 我是在VMware下装的CentOS7 第一步配置硬件 先创建一个虚拟机 这里我选择的典型模式,新手嘛,新手难度的创建就好,高手难度的等新手难度熟练了再去碰好了,当然这是我的建议… 下一步然后光盘选择稍后…

    2017-07-15
  • 马哥教育网络班20期第2周课程练习

    答: 1、 cp,mv,rm,cat(tac,more,less,tail),touch 其中常用的有: cp(复制):                   -i:交互式              -…

    Linux干货 2016-06-23
  • linux三剑客之grep

    linux三剑客之grep        所谓三剑客的工具有“grep”、“sed” 、“awk”,他们都是不谋而合的文本搜索查找处理的强大工具。grep 是 Ken Thompson 写的,他也是 Unix 的创造者。 gerp及正则表达式    grep全称(GLobal search Regu…

    Linux干货 2016-08-08
  • 正则表达式简述

    正则表达式简述 什么是正则表达式: 正则表达式,又称正规表示法、常规表示法(英语:Regular Expression,在代码中常简写为regex、regexp或RE),计算机科学的一个概念。正则表达式使用单个字符串来描述、匹配一系列符合某个句法规则的字符串。在很多文本编辑器里,正则表达式通常被用来检索、替换那些符合某个模式的文本。 正则表达式分类: 标准正…

    Linux干货 2016-04-05
  • grep虐我千百遍,我待grep如初恋

    N21第四周博客作业 1、  复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 [root@Centos6 ~]# cp -r /etc/skel /home/tuser1 [root@Centos6 ~]#…

    Linux干货 2016-07-16