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

、创建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 14:42
下一篇 2016-08-04 14:42

相关推荐

  • Vim编辑器使用详解

    Vim编辑器使用详解 vim介绍 为什么要学习vim vim三种模式 vim工作模式(图解) vim如何打开文件 vim关闭文件 命令模式光标跳转 字符间跳转: 单词间跳转: 行首行尾跳转: 行间移动: VIM的命令模式下的命令: 字符编辑: 替换命令(r, replace) 删除命令: 复制命令 粘贴命令(p, paste): : 其他相关的编辑操作: 翻…

    Linux干货 2016-09-06
  • 小东北Eric的学习宣言

      大家好,我是网络班24期新加入的学员,之前工作了几年,一直没有找到一个很明确的工作方向,现在终于可以有一个很明确的努力方向啦,那就是跟着马哥,成为技术大牛,听马哥说过,键盘敲烂,月薪两万,为了这个目标,并且努力超越它,加油!冲!冲!冲!

    Linux干货 2016-10-19
  • 文件系统

    文件系统 文件和目录被组织成一个单根倒置树结构 文件系统从根目录下开始,用“/”表示 文件名称区分大小写 以.开头的文件为隐藏文件   一个.表示本目录。 两个..表示根目录 路径分隔的/      路径分割为正斜线分割 文件有两类数据:        元数据:metadata …

    Linux干货 2017-05-02
  • N26-第一周

    描述计算机的组成及功能。 计算机主要由运算器,控制器,存储器,输入、输出设备五大部件组成 运算器(Arithmetic Logic Unit, ALU):实现各种算数运算和逻辑运算(与控制器组成cpu)。 控制器(Control Unit, CU):计算机控制中心,根据程序规定的控制程序进行解释,根据要求进行调度,控 制协调各部分有条不紊的运行。 存储器(M…

    Linux干货 2017-02-03
  • N21沉舟第九周作业

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; 方法一: #!/bin/bash         #     dec…

    Linux干货 2016-08-30
  • linux获取”命令帮助“

    一、相关术语:         外部命令:一个可执行程序,位于文件系统某目录下;是系统为了完善各种功能而加入的程序。         内部命令:系统shell程序的部分程序。内部命令执行速度非常快,其…

    Linux干货 2016-06-09