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 ~]# getent passwd testuser
testuser:x:1234:1::/testdir/testuser:/bin/csh

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

[root@localhost ~]# usermod -u 4321 -g root -G nobody -l test -md /home/test testuser
[root@localhost ~]# getent passwd test
test:x:4321:0::/home/test:/bin/csh
[root@localhost ~]# ls -a /home/test/
.  ..  .bash_logout  .bash_profile  .bashrc  .gnome2  .mozilla

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

[root@localhost ~]# vim homework.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 homework.txt
[root@localhost ~]# vim homeworkpw.txt
    user1:user1pass
    user2:user2pass
    user3:user3pass
    user4:user4pass
    user5:user5pass
    user6:user6pass
    user7:user7pass
    user8:user8pass
    user9:user9pass
    user10:user10pass
[root@localhost ~]# cat homeworkpw.txt | chpasswd
[root@localhost skel]# cp -r /etc/skel/.[^.]* /testdir/user1 
    ...将/etc/skel目录下的文件分别复制到每个用户家目录
    cp -r /etc/skel/. /testdir/user10

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

(0)
paopao
上一篇 2016-08-03 19:05
下一篇 2016-08-03 19:07

相关推荐

  • 常见文件管理命令及bash特性

    cat:查看文件文本内容  -n:显示行号  [root@study ~]# cat -n /etc/passwd  1  root:x:0:0:root:/root:/bin/bash  2  bin:x:1:1:bin:/bin:/sb…

    系统运维 2016-11-06
  • Linux运维之进程管理

    一、      进程概念 进程是内核的一个功能,在Linux中,运行一个程序或命令可以出发一个事件而驱动一个PID,在linux系统中,系统只识别二进制程序文件,我们可以通过执行系统上的二进制程序来运行程序,进而产生进程。在linux系统中第一个进程是init程序,它是系统开机第一个加载的程序,用来支撑系统的…

    Linux干货 2016-09-13
  • linux基础学习-第八天

    2016-08-08 授课内容: 处理文本的工具sed vim编辑器 Shell脚本编程基础介绍 sed:sed是一种流编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),     接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。默认不编辑原文件,仅…

    Linux干货 2016-08-10
  • 揭开链接文件的面纱——从根本上剖析硬链接与软链接异同

    在linux的学习过程中,链接文件的学习让不少人头疼,很多同学往往分不清什么是硬链接,什么是软链接,对于两者的概念和区别常常容易混淆、搞不清楚。今天我们就从原理、从根本上为大家辨析一些两者之间的区别,相信大家在看完这篇文章之后对链接文件会有一个清晰正确的认识。 1、在实现原理上不同 硬链接,涉及到文件的底层模式,因此被称为硬链接文件。硬链接文件只是一个指针指…

    Linux干货 2016-10-20
  • 用户和组命令的简单使用

    用户和组管理命令: 用户管理命令:useradd usermod userdel 组管理命令:groupadd groupmod groupdel 用户创建:useradd -u:uid 定义在/etc/login.defs -o:配合-u选项,不检查uid的唯一性 -g:gid,指明用户所属基本组,可为组名,也可以gid -c:用户的诠释信息 -d;指定用…

    Linux干货 2016-10-24
  • sed命令的入门与进阶

    sed:Stream EDitor     什么是sed呢?sed被称为linux文本处理三剑客之一,另外两个就是大名鼎鼎的grep和awk。sed是非交互性的流编辑器,在处理文本时一次只读取一行文本,然后基于所给定的编辑脚本对模式空间中的内容做编辑处理并把处理后的结果输出至标准输出。接着处理下一行文本,这样不断重复,直到文件的末尾。se…

    2017-03-16