8.1作业

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

[root@localhost wang]# useradd -G bin,root -s /bin/csh -c "Gentoo distribution" gentoo
[root@localhost wang]# getent passwd gentoo
gentoo:x:2004:2004:Gentoo distribution:/home/gentoo:/bin/csh

创建下面的用户、组和组成员关系

名字为admins的组

用户natasha,使用admins 作为附属组

用户harry,也使用admins作为附属组

用户sarah,不可交互登录系统,且不是admins的成员

natasha,harry,sarah密码都是centos

[root@localhost wang]# groupadd admins
[root@localhost wang]# useradd -G admins natasha
[root@localhost wang]# useradd -G admins harry
[root@localhost wang]# useradd -s /sbin/nologin sarah
[root@localhost wang]# echo "centos" | passwd --stdin natasha
Changing password for user natasha.
passwd: all authentication tokens updated successfully.
[root@localhost wang]# echo "centos" | passwd --stdin harry 
Changing password for user harry.
passwd: all authentication tokens updated successfully.
[root@localhost wang]# echo "centos" | passwd --stdin sarah 
Changing password for user sarah.
passwd: all authentication tokens updated successfully.
[root@localhost wang]#

一次创建多个用户并配置密码

[root@localhost ~]# vi user.txt

linux1:x:2001:2001::/home/linux1:/bin/bash
linux2:x:2002:2002::/home/linux2:/bin/bash
linux3:x:2003:2003::/home/linux3:/bin/bash
~                                                                                     
~                                                                                     
~
[root@localhost ~]# newusers user.txt
[root@localhost ~]# ls /home
gentoo  harry  linux1  linux2  linux3  mageedu  natasha  sarah
[root@localhost ~]# cat /etc/passwd    
...
...
...  
linux1:x:2001:2001::/home/linux1:/bin/bash
linux2:x:2002:2002::/home/linux2:/bin/bash
linux3:x:2003:2003::/home/linux3:/bin/bash
[root@localhost ~]# vi passwd.txt

linxu1:123456
linux2:234567
linux3:345678
~                                                                                     
~                                                                                     
~                                                                                     
~                                                                                     
[root@localhost ~]# cat passwd.txt | chpasswd  
[root@localhost ~]# cp /etc/skel/.[^.]* /home/linux1

创建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 -m testuser
[root@localhost /]# id  testuser
uid=1234(testuser) gid=1(bin) groups=1(bin),0(root),50(ftp)
[root@localhost /]# groups testuser 
testuser : bin root ftp

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

[root@localhost /]# usermod -u 4321 -g root -G nobody -l test -d /home/test -m testuser 
[root@localhost /]# id test
uid=4321(test) gid=0(root) groups=0(root),99(nobody)
[root@localhost /]# groups test 
test : root nobody

批量创建帐号 user1-user10 uid:3000-3009 shell:/bin/csh home:testdir/user 密码:user1pass

[root@localhost /]# vi user.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 user.txt  
[root@localhost /]# vi passwd.txt

user1:user1pass
user2:user2pass
user3:user3pass
user4:user4pass
user5:user5pass
user6:user6pass
user7:user7pass
user8:user8pass
user9:user9pass
user10:user10pass
~                                                                                     
~                   
[root@localhost /]# cat passwd.txt | chpasswd   
[root@localhost ~]# cp /etc/skel/.[^.]* /testdir/user1
cp: omitting directory ‘/etc/skel/.mozilla’
[root@localhost ~]# su - user1
[user1@localhost ~]$ exit
logout
[root@localhost ~]#

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

(0)
DYWDYW
上一篇 2016-08-02 16:58
下一篇 2016-08-02 19:47

相关推荐

  • 磁盘管理进阶–RAID–LVM初步应用

    配置配额系统 综述   在内核中执行   以文件系统为单位启用   对不同组或者用户的策略不同 根据块或者节点进行限制 执行软限制( soft limit)硬限制( hard limit) 初始化 分区挂载选项: usrquota、 grpquota 在创建好分区后, 对/etc/fstab 进行修改 , 加入 后加进来的分区的…

    Linux干货 2016-09-01
  • 从增删改查角度学习linux基础命令

    从增删改查角度学习linux基础命令   本文从文件的增加、删除、修改、查询四个角度介绍linux的基本命令,介绍如下:   一.增 touch命令是最常用的创建文件的命令,它的常见参数如下: -a 或–time=atime或–time=access或–time=use  只更改存取时间。 -c 或&#…

    2017-07-15
  • 程序包管理的前端工具YUM及案例一二

    程序包管理前端工具–YUM        yum:yellowdog update modifier        yum工具为CS架构 yum仓库(yum repository):yum repo   &n…

    Linux干货 2016-08-24
  • 浅谈群红包的实现

    前言:红包是支付的方式, 也是社交的延伸。群红包在这两块领域串联得很好, 表现尤为的浓墨重彩. 承接上两篇技术浅谈:1). 浅谈接龙红包的技术实现.2). 浅谈微信红包摇一摇的技术实现.这一次, 让我们谈谈群红包的技术实现. 一为是红包的分配算法, 二为竞抢的技术实现. 分配算法:最初玩群红包的时候, 并没有意识到分配算法的难度…

    Linux干货 2015-03-10
  • 配额-and-RAID

    配置配额系统 控制单个用户,或组在某磁盘上所能占的最大空间大小 配额是基于磁盘分区的,不基于文件 如何基于软件控制配额:          1、设置分区挂载选项          &nbsp…

    Linux干货 2016-08-29
  • 计算机基础知识点

    说明:(仅仅记录个人认为重要的内容) CPU的相关概念 主频:主频是cpu的时钟频率(cpu clock speed),是cpu运算时的工作频率(1秒内发生的同步脉冲数) 的简称。单位是HZ,一般 来说,主频越高,cpu的速度越快。由于内部结构的不同,并非所有的时钟频率 相同的cpu的性能都一样  外频:系统…

    Linux干货 2017-02-14