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)
上一篇 2016-08-08 09:22
下一篇 2016-08-08 09:22

相关推荐

  • 文本处理三兄弟(grep,sed,awk)

    linux文本处理三剑客: grep:文本过滤工具 grep  egrep=grep -e  fgrep sed:流编辑器  处理多个行  awk:文本编辑工具,格式化工具 grep [OPTIONS] PATTERN [FILE…] : 文本处理搜索工具,根据用户指定的“模式”对目标文本进行匹配检查;打印匹…

    Linux干货 2017-04-01
  • 文件的权限详解(二)ACL篇

    文件的权限详解(二)ACL篇 ACL访问控制列表作用: 1、 ACL:Access Control List,实现灵活的权限管理2、 除了文件的所有者,所属组和其它人,可以对更多的用户设置权限3、 CentOS7.0默认创建的xfs和ext4文件系统有ACL功能。4、 CentOS7.X之前版本,默认手工创建的ext4文件系统无ACL功能。需手动增加: tu…

    Linux干货 2016-08-05
  • 正则表达式之一grep

    grep :文本过滤( 模式:pattern) 工具 包括:grep, egrep, fgrep (不 支持正则表达式 搜索) 用法格式: grep [OPTIONS] PATTERN [FILE…]            &n…

    2017-02-27
  • 正则表达式—正则表达式详解

    grep使用正则表达式进行匹配时,将大大提高效率和精准性,正则表达式概括分为基本正则表达式和扩展正则表达式。 一、基本正则表达式   字符匹配元字符         .        &nb…

    Linux干货 2016-07-04
  • linux基础学习之AWK

    内容: 1、awk输出(print、printf) 2、awk变量(内建变量和定义变量) 3、awk数组 4、awk重定向输出 5、awk操作符 6、awk常见模式类型 7、awk控制及循环语句 8、awk内置函数 awk:(其名称得自于它的创始人 Alfred Aho 、Peter Weinberger 和 Brian Kernighan 姓氏的首个字母)…

    Linux干货 2016-09-22
  • N25-第四周

    一、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。     [root@localhost ~]# cp -r /etc/skel /home/tuser1      [root@localhost ~]# chmo…

    Linux干货 2017-01-09