系统基础之用户,组管理作业题

、创建testuser uid 1234,主组:bin,辅助组:root,ftp,shell:/bin/csh home:/testdir/testuser

1
2
3
[root@wen-7 ~]# useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser
[root@wen-7 ~]# getent passwd testuser 
testuser:x:1234:1::/testdir/testuser:/bin/csh

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

1
2
3
[root@wen-7 ~]# usermod -l test -u 4321 -g root -G nobody -d /home/test -m  testuser
[root@wen-7 ~]# getent passwd test
test:x:4321:0::/home/test:/bin/csh


3、批量创建帐号:user1…user10

uid:3000-3009,shell:/bin/csh,home:/testdir/username

passwd:usernamepass

注意家目录相关配置,使用户正常登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
[root@w6 ~]# mkdir /testdir
[root@w6 ~]# cat  user.sh 
user1:x:3001:3001::/testdir/user1:/bin/csh
user2:x:3002:3002::/testdir/user2:/bin/csh
user3:x:3003:3003::/testdir/user3:/bin/csh
user4:x:3004:3004::/testdir/user4:/bin/csh
user5:x:3005:3005::/testdir/user5:/bin/csh
user6:x:3006:3006::/testdir/user6:/bin/csh
user7:x:3007:3007::/testdir/user7:/bin/csh
user8:x:3008:3008::/testdir/user8:/bin/csh
user9:x:3009:3009::/testdir/user9:/bin/csh
user10:x:3010:3010::/testdir/user10:/bin/csh
[root@w6 ~]# newusers user.sh 
[root@w6 ~]# tail -10 /etc/passwd
user1:x:3001:3001::/testdir/user1:/bin/csh
user2:x:3002:3002::/testdir/user2:/bin/csh
user3:x:3003:3003::/testdir/user3:/bin/csh
user4:x:3004:3004::/testdir/user4:/bin/csh
user5:x:3005:3005::/testdir/user5:/bin/csh
user6:x:3006:3006::/testdir/user6:/bin/csh
user7:x:3007:3007::/testdir/user7:/bin/csh
user8:x:3008:3008::/testdir/user8:/bin/csh
user9:x:3009:3009::/testdir/user9:/bin/csh
user10:x:3010:3010::/testdir/user10:/bin/csh         
[root@w6 ~]# cat passwd.sh |chpasswd 
[root@w6 ~]# cat passwd.sh 
user1:user1pass
user2:user2pass
user3:user3pass
user4:user4pass
user5:user5pass
user6:user6pass
user7:user7pass
user8:user8pass
user9:user9pass
user10:user10pass
 
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user1
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user2
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user3
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user4
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user5
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user6
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user7
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user8
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user9
[root@w6 ~]# cp -r /etc/skel/.[^.]* /testdir/user10
[root@w6 ~]# ll -a /testdir/user1
total 32
drwx------.  4 user1 user1 4096 Jul 30 16:58 .
drwxr-xr-x. 12 root  root  4096 Jul 30 16:53 ..
-rw-r--r--.  1 root  root    18 Jul 30 16:58 .bash_logout
-rw-r--r--.  1 root  root   176 Jul 30 16:58 .bash_profile
-rw-r--r--.  1 root  root   124 Jul 30 16:58 .bashrc
drwxr-xr-x.  2 root  root  4096 Jul 30 16:58 .gnome2
-rw-------.  1 user1 user1   53 Jul 30 16:56 .history
drwxr-xr-x.  4 root  root  4096 Jul 30 16:58 .mozilla
[root@w6 ~]# ll -a /testdir/user2

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

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

相关推荐

  • 如何解决生产机上php代码连接mysql报错的故障

    大家好: 今天分享一则当生产机上的网站php代码不能连接Mysql服务器时怎么办? 当LNMP的网站建立好后,我们需要测试网站中的php代码。但发现如下报错怎么办? 解决方法如下:  mysql> show databases; +——————–+ | Dat…

    Linux干货 2016-12-18
  • Linux基础之计算机的组成及其功能

    1、描述计算机的组成及其功能: 答:计算机由 1.1、CPU(运算器、控制器)进行逻辑运算跟控制运算,寄存器、缓存 1.2、输入单元(键盘、鼠标、手写板等)、输出单元(屏幕、打印机) 1.3、存储器(内存、硬盘) 2、按系列罗列linux的发行版,并描述不同发行版之间的联系与区别。 答:debian(ubuntu、mint、knopix)、slackware…

    2017-09-11
  • iptables:防火墙以及网络协议基本原理

    一、 Linux 网络安全模型      1. 防火墙: 工作在主机或者网络边缘,对进出报文使用实现定义的规则进行检测,并且由匹配的规则进行处理的一组硬件或者软件。也可能两者结合。          1) 通常使用的防火…

    Linux干货 2015-07-24
  • 搭建简单的ftp和http

    搭建简单的ftp和http 我们主要尝试光盘和编译两种方式安装 ftp 首先我们先安装ftp ftp可以用来做文件传输,也可以搭建ftp作为我我们的网络yum源 首先我们要先把镜像连接到我们的Linux中 进入/etc/yum.repos.d/创建一个.repo结尾的文件,在里面配置自己的yum源 [base] baseurl=file:///misc/cd…

    2017-06-15
  • 马哥教育网络21期+第十二周练习博客上

    1、请描述一次完整的http请求处理过程; (1)建立或处理连接:接受请求或拒绝请求 (2)如果接受请求:     并发访问响应模型:         单进程I/O结构:启动一个进程处理用户请求,而且一次只处理一个,多个请求被串行响应; &…

    Linux干货 2016-10-17
  • 搭建LAMP+NFS(附加mysql共享NFS目录练习总结)

    练习一 环境布局: 主机6 route A (10.1.32.14)作为DNS服务器 主机centos 7 class (10.1.32.3)作为Apache,PHP(模块方式)服务器1(有discuz程序) 主机centos 7 server (10.1.32.13)作为Apache,php(模块方式)服务器2(无discuz) 主机centos 6 cl…

    系统运维 2016-10-25