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
下一篇 2016-08-02

相关推荐

  • N22-妙手-第十周博客作业

    1、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情)     (1) POST阶段         加电自检,确保每个设备能正常工作     (2) BIOS  &nb…

    Linux干货 2016-12-05
  • Linux DNS服务系列之原理介绍及正反向解析配置

    前言 我们在访问一个网站的时候,只要输入该网站的网址就会跳转到该网站页面,而实现这一过程就需要DNS服务器将域名解析为IP地址,进而实现数据通信。那么DNS服务器是如何工作的呢?本系列分为两部分,本文将详解DNS服务原理及正反向解析配置。 DNS服务原理详解 DNS相关知识 DNS:Domain Name Service,域名解析服务 监听端口:udp/53…

    Linux干货 2015-04-13
  • Linux进程及作业管理

    process 运行中的程序的一个副本,是被载入内存的一个指令集合 进程ID(Process ID,PID)号码被用来标记各个进程 UID、GID、和SELinux语境决定对文件系统的存取和访问权限, 通常从执行进程的用户来继承 存在生命周期 task struct:Linux内核存储进程信息的数据结构格式 task list:…

    Linux干货 2016-09-11
  • Linux的自动化安装实现

    在介绍自动化安装系统之前让我们来回顾一下系统的启动流程,系统的启动大概分为一下几个步骤:加电自检 boot sequence(mbr)— boot loader –>kernel(initramfs)—>rootfs  /sbin/init大概就是这么几个过程了,接下来来介绍系统的安装,安装系统虽然看起来简单,普…

    系统运维 2016-09-19
  • 软件包管理

    rpm 与 yum 的用法 源代码:name-VERSION.tar.gz|bz2|xz VERSION: major.minor.release rpm包命名方式: name-VERSION-release.arch.rpm 例:bash-4.2.46-19.el7.x86_64.rpm VERSION: major.minor.release rele…

    Linux干货 2016-09-01
  • 做有高薪有逼格的运维工程师,不会Linux是没有前途的!

    作为互联网的幕后英雄,运维工程师长期隐匿在大众认知范围之外,关于运维的讨论仍旧是一片无人涉足的荒漠。在某知名行业研究调查结果中,非互联网从业者对于运维相关问题的回复有三个高频词汇是:不知道、没听过、网管。当调查人员告诉他们科幻电影中展示黑客高超技巧时的命令行界面正是大多数运维工程师每日工作环境时,他们发出极其一致的惊叹。 相对于普罗大众的一无所知,技术圈对运…

    2017-09-08