8.1作业

8月1日作业

  1. 创建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 testuser
[root@localhost ~]# tail -1 /etc/passwd
testuser:x:1234:1::/testdir/testuser:/bin/csh
[root@localhost ~]# id testuser
uid=1234(testuser) gid=1(bin) groups=1(bin),0(root),50(ftp)

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

[root@localhost ~]# usermod -u 4321 -g 0 -G 99 -md /home/test -l test testuser
[root@localhost ~]# id test
uid=4321(test) gid=0(root) groups=0(root),99(nobody)
[root@localhost ~]# tail -1 /etc/passwd
test:x:4321:0::/home/test:/bin/csh

3.批量创建帐号:user1…user10 uid:3000-3009,shell:/bin/csh,home:/testdir/username passwd:usernamepass 注意家目录相关配置,使用户正常登录 此题因为用户太多,因此最后显示了一个用户成功,即为实验成功。

8.1作业

[root@localhost ~]# newusers user.txt 
[root@localhost ~]# tail /etc/passwd
niu1:x:3000:3000::/testdir/username:/bin/csh
niu2:x:3001:3001::/testdir/username1:/bin/csh
niu3:x:3002:3002::/testdir/username2:/bin/csh
niu4:x:3003:3003::/testdir/username3:/bin/csh
niu5:x:3004:3004::/testdir/username4:/bin/csh
niu6:x:3005:3005::/testdir/username5:/bin/csh
niu7:x:3006:3006::/testdir/username6:/bin/csh
niu8:x:3007:3007::/testdir/username7:/bin/csh
niu9:x:3008:3008::/testdir/username8:/bin/csh
niu10:x:3009:3009::/testdir/username9:/bin/csh


[root@localhost ~]# vim user.txt
[root@localhost ~]# newusers user.txt 
[root@localhost ~]# tail /etc/passwd
niu1:x:3000:3000::/testdir/username:/bin/csh
niu2:x:3001:3001::/testdir/username1:/bin/csh
niu3:x:3002:3002::/testdir/username2:/bin/csh
niu4:x:3003:3003::/testdir/username3:/bin/csh
niu5:x:3004:3004::/testdir/username4:/bin/csh
niu6:x:3005:3005::/testdir/username5:/bin/csh
niu7:x:3006:3006::/testdir/username6:/bin/csh
niu8:x:3007:3007::/testdir/username7:/bin/csh
niu9:x:3008:3008::/testdir/username8:/bin/csh
niu10:x:3009:3009::/testdir/username9:/bin/csh
[root@localhost ~]# [root@localhost ~]# tail /etc/passwd
bash: [root@localhost: command not found...
[root@localhost ~]# niu1:x:3000:3000::/testdir/username:/bin/csh
-bash: niu1:x:3000:3000::/testdir/username:/bin/csh: No such file or directory
[root@localhost ~]# niu2:x:3001:3001::/testdir/username1:/bin/csh
-bash: niu2:x:3001:3001::/testdir/username1:/bin/csh: No such file or directory
[root@localhost ~]# niu3:x:3002:3002::/testdir/username2:/bin/csh
-bash: niu3:x:3002:3002::/testdir/username2:/bin/csh: No such file or directory
[root@localhost ~]# niu4:x:3003:3003::/testdir/username3:/bin/csh
-bash: niu4:x:3003:3003::/testdir/username3:/bin/csh: No such file or directory
[root@localhost ~]# niu5:x:3004:3004::/testdir/username4:/bin/csh
-bash: niu5:x:3004:3004::/testdir/username4:/bin/csh: No such file or directory
[root@localhost ~]# niu6:x:3005:3005::/testdir/username5:/bin/csh
-bash: niu6:x:3005:3005::/testdir/username5:/bin/csh: No such file or directory
[root@localhost ~]# niu7:x:3006:3006::/testdir/username6:/bin/csh
-bash: niu7:x:3006:3006::/testdir/username6:/bin/csh: No such file or directory
[root@localhost ~]# niu8:x:3007:3007::/testdir/username7:/bin/csh
-bash: niu8:x:3007:3007::/testdir/username7:/bin/csh: No such file or directory
[root@localhost ~]# niu9:x:3008:3008::/testdir/username8:/bin/csh
-bash: niu9:x:3008:3008::/testdir/username8:/bin/csh: No such file or directory
[root@localhost ~]# niu10:x:3009:3009::/testdir/username9:/bin/csh
-bash: niu10:x:3009:3009::/testdir/username9:/bin/csh: No such file or directory
[root@localhost ~]# 
[root@localhost ~]# vim passwd.txt
[root@localhost ~]# cat passwd.txt 
niu1:usernamepass
niu2:usernamepass
niu3:usernamepass
niu4:usernamepass
niu5:usernamepass
niu6:usernamepass
niu7:usernamepass
niu8:usernamepass
niu9:usernamepass
niu10:usernamepass
[root@localhost ~]# cat passwd.txt  |chpasswd 
[root@localhost ~]# tail /etc/shadow
niu1:$6$WXiO3VmN$4OgPAkSzGwiBQiYw/gKVJehBOBVPK4NuNba8IWHfaCJ8tuwM/GUlBFM.vLH5JQbErE1PEJ9UIvnobZ6yezUeY.:17015:0:99999:7:::
niu2:$6$b9gzw7SK$fR9xidWkNzI2WPvNbN3MU6BX7bkVTgzNdd/Xi4aAHzFazJlFM0nag5kDFp9US7tBkvuRE2HOdXrvSB3fF8m4t1:17015:0:99999:7:::
niu3:$6$UiPsk/b01MsVo/Y$GGSXqr.hgo2v3S0Te.ouQNfQLramLrw5DXPmqpanLVUogTebAgJc90snjBErjD/vw64eNNE0YNoenur/lhhIi.:17015:0:99999:7:::
niu4:$6$tljwV/POq$stgnqDlgeQZdHBRDx6xQ5cQ4Q981qfnSkCTPHeWaj5nmhQZMSAlPPQHuKFxDDd.3lTTYKBZvHzFwdfWiNKGSK1:17015:0:99999:7:::
niu5:$6$VjrEk/g4L9HQQJhC$XeReNC3o0aX38x1GpauS2jJz3O7a.G1ZsNNKEIEzUacBwb3m30txEJnZsp8.FiRz3BBY.LMsz5xB4taHhWaIw1:17015:0:99999:7:::
niu6:$6$2Ha.d/nM7G.$DFoa1cUilw7ChEYDkK2f5GWPNXalZ2C5jhri9teO80ussEmdc1HHgc0EbFTQoBcXmPHyxsLTklN0.7XbRusUR/:17015:0:99999:7:::
niu7:$6$XRSHd/bpv$KadPAQbYmMuPeKDnPJ54QY9TOsFf9Ew.f0SZT2GRqpuiOARLxTBmUnEpk5oTj6PqAeC1JIaWZxc.RiYWJD2YF/:17015:0:99999:7:::
niu8:$6$I1oQI3jd$3DFgubf9j0cDfivB5KdYuESQXpGJSZQpki9u.l8SwcwYQzrZlhRwi68nJ5U6LFkLkjYJ549d12Onp5InuKejx0:17015:0:99999:7:::
niu9:$6$f6rwb16B$AtGuH357U7GXEygwI/naCwcCzkN8.xhPjf5n0VfzrHvh06lFhErFkalMuBPeim8MT8wKUU5hTHtIU9IE/9pXZ/:17015:0:99999:7:::
niu10:$6$N18Me/fnAwmhMQo$IQFb5wMcjvQ2dYXo6hiFXKIgYA9z8FdCKonmCWsz/.PcUauWbEhGan3wEFjFA63L3dumqzaDYBgMV9C4YQRy3/:17015:0:99999:7:::


[root@localhost username]# cp -r /etc/skel/.[^.]* /testdir/username4
[root@localhost username]# cd ..
[root@localhost testdir]# cd username4
[root@localhost username4]# ls -A
.bash_logout  .bash_profile  .bashrc  .mozilla
[root@localhost username4]# cd ..
[root@localhost testdir]# cd username2
[root@localhost username2]# ls -A
.bash_logout  .bash_profile  .bashrc  .mozilla
[root@localhost username2]# su - niu2
[niu2@localhost ~]$

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

(0)
fighterfighter
上一篇 2016-08-04
下一篇 2016-08-04

相关推荐

  • CentOS 6启动过程总结与GRUB问题修复

    一、CentOS 6 的启动流程 第一步:加电自检(POST) 主要检查硬件设备是否存在并能正常运行,如:CPU、内存、硬盘、风扇、输入输出设备等。自检功能主要是通过BIOS来实现的,BIOS程序是装载在一个硬件芯片CMOS上的,加电过程就是给CMOS通电,然后启动BIOS程序,BIOS程序会根据CMOS上面的一些配置信息区读取其他的硬件设备信息并检测其是否…

    Linux干货 2016-09-16
  • vim编辑器

    一、vim编辑器简介     文本:ASCII,Unicode     文本编辑种类:     行编辑器:sed     全屏编辑器:nano,vi     v…

    Linux干货 2016-08-10
  • 正则表达式入门

    正则表达式入门 谈到正则表达式,我们就得先了解一下POSIX。POSIX的全称是Portable Operating System Interface foruniX,它由一系列规范构成,定义了UNIX,linux操作系统应当支持的功能,它定义了BRE(Basic Regular Expression,基本型正则表达式)和ERE(Extended Regul…

    2017-07-29
  • N22-第六周作业

    vim小小的总结 (本总结摘自马哥网络班22期课堂笔记) vim是一款交互式的全屏编辑器,是vi的升级版,在vi上增强了很多,如:多级撤销,多窗口和多缓冲区,语法高亮,在线帮助等。 vim也是一种模式化的编辑器。分别是编辑模式也叫命令模式,输入模式,末行模式。其中使用vim打开文件后默认的是编辑模式。 三种模式之间的转换: 编辑模式—>输入模式 &…

    Linux干货 2016-11-21
  • shell编程、查找命令、压缩文件工具

    shell编程、查找命令、压缩文件工具  shell编程 一、条件测试  1、判断某需求是否满足,需要由测试机制来实现。    测试命令:  ·test Expression  ·[ EXPRESSION ]  ·[[ EXPRESSION ]]   &nbs…

    Linux干货 2016-08-15
  • 使用mysql-mmm实现高可用mysql读写分离

    MMM介绍:  MMM全称为Multi-Master Replication Manager for MySQL,即为主主复制管理器;根据MMM官网介绍,其工作原理类似于lvs,都是利用vip地址;但lvs只有一个组件便可以正常工作,而MMM则使用三个组件,分别是mysql-mmm、mysql-mmm-agent、mysql-mmm-monitor…

    Linux干货 2015-08-04