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

相关推荐

  • shell-变量

    bash中变量的种类 根据变量的生效范围等标准:     本地变量:生效范围为当前shell进程;对当前shell之外的其它shell进程,包括当前shell的子shell进程均无效     环境变量:生效范围为当前shell进程及其子进程    …

    Linux干货 2016-08-21
  • 初识Linux基础

    一:计算机的组成及其基本功能 计算机主要由五大基础部件组成:控制器,运算器,存储器,输入设备,输出设备。 1、控制器:计算机的核心组件,协调各程序的运行,对计算机的各项资源进行控制分配; 2、运算器:计算机实现算术运算以及逻辑运算的部件; 3、存储器:计算机用来存放数据和程序的基本部件,存储器由若干存储单元组成,每个存储单元都有一个             …

    Linux干货 2018-03-04
  • grub详解

    grub详解 1、GRUB(Boot Loader): grub:grub 0.x:grub1 legacy传统的版本 grub 1.x:grub2 grub legacy: 第1阶段:mbr 第1.5阶段:mbr之后的扇区中,让第一阶段中的boot loader能识别第二阶段所在分区上的文件系统 第2阶段:磁盘分区(/boot/grub/) 配置文件/et…

    2017-09-03
  • 字符串处理

      一.字符串处理 v bash 的字符串处理工具: (一)字符串切片: ${#var}: 返回字符串变量var 的长度 例: [root@lxc ~]# a="     " [root@lxc ~]# echo ${#a} 5 [root@lxc ~]# ${var:offse…

    Linux干货 2016-11-24
  • > 输出重定向

    重定向输出 > >> 追加 目 录 1、 >正确定向等同于1> 2、 2> 错误定向 3. &> 把错误导成正确的{洗钱} 4. 正确的变成错误的 5. > 覆盖 6. 举一反三 最近学的命令中学到了一些很有意思的命令,分享一下 > 重定向输出 最…

    Linux干货 2017-08-13
  • Linux高级文件系统管理之磁盘配额、RAID和LVM的使用

    磁盘配额Quota 磁盘配额(Quota)的作用:   在Linux系统中,由于是多用户、多任务的环境,所以会有多用户共同使用一个硬盘空间的情况发生,如果其中有少数几个用户大量占掉了硬盘空间的话,那肯定影响其他用户的使用权限。因此管理员应该适当限制硬盘的空间给用户,以妥善分配系统资源。 磁盘配额的一般用途    比较常使用的几种…

    Linux干货 2016-09-02