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

、创建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

相关推荐

  • 6、vim编辑和查找和特殊权限

    http://note.youdao.com/yws/public/redirect/share?id=dd29f6f6ad717181cdd6d01bbf8db554&type=false

    Linux干货 2016-08-08
  • 源码包编译安装MariaDB-10.1.22

    源码包编译安装MariaDB-10.1.22 1、获取源码包        mariadb-10.1.22.tar.gz 2、编译环境及依赖关系     yum groupinstall -y Development Tools yum -y install …

    Linux干货 2017-03-16
  • MySQL备份与恢复

    备份与恢复 数据备份就是将数据以某种方式加以保留,以便在系统需要时重新恢复和利用。其作用主要体现在如下两个二方面: 在数据遭到意外事件破坏时,通过数据恢复还原数据 数据备份是历史数据保存归档的最佳方式 数据恢复就是把遭到破坏、删除和修改的数据还原为可使用的数据的过程 为什么要备份数据? 在生产环境中我们数据库可能会遭遇各种各样的不测从而导致数据丢失, 大概分…

    Linux干货 2016-11-25
  • 精解局域网访问及共享(三)

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://jeffyyko.blog.51cto.com/28563/155109    上一节中的2种情况都是默认的简单共享,下面我们着重分析一下高级共享方式下的各种访问情况。毕竟这种方式用的很普遍,而且在权限…

    Linux干货 2015-03-25
  • vim

    VIM常用操作命令 模式转换 1、ESC键:编辑模式 --> 一般模式;2、从一般模式 --> 编辑模式 i:在光标所在处的前方转换为编辑模式 a:在光标所在处的后方转换为编辑模式 o:在光标所在行的下方新建一个空行并转换为编辑模式 I:在光标所在行的行首输入 A:在光标所在行的行尾输入 O:在光标所在行的上方新建一个空白行 3、一般模式 --> 末行模式:…

    Linux干货 2017-04-06
  • Linux进程查看及管理(2)

    Linux进程查看及管理(2) CentOS5和6的启动流程: Liunx中的启动:kernel和rootfs(根文件系统) kernel:进程管理,内存管理,网络管理功能,驱动程序,文件系统,安全功能(权限模型), rootfs:glibc(lib,lib64) 库:函数集合,function(功能模块)有其调用接口(头文件是对函数功能或调用参数的功能进行…

    Linux干货 2016-08-08