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

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

相关推荐

  • Linux系统网络属性管理之bond

    Bonding 就是将多块网卡绑定同一IP地址对外提供服务,可以实现高可用或者负载均衡。当然,直接给两块网卡设置同一IP地址是不可能的。通过bonding,虚拟一块网卡对外提供连接,物理网卡的被修改为相同的MAC地址。 Bonding的工作模式 •Mode 0 (balance-rr) 轮转(Round-robin)策略:从头到尾顺序的在每一个slave接口…

    Linux干货 2016-09-18
  • Linux之计划任务

    Linux 之计划任务    任务计划Linux任务计划、周期性任务执行未来的某时间点执行一次任务:atbatch:系统自行选择空闲时间去执行此处指定的任务周期性运行某任务:cron   at任务at命令:at [option] TIME常用选项:-V 显示版本信息:-l: 列出指定队列中等待运行的作业;相当于atq-d: 删除…

    Linux干货 2016-09-11
  • shell脚本编写-5

      1、 数组 变量:存储单个元素的内存空间 数组:存储多个元素的连续的内存空间,相当于多个变量的集合 数组名和索引 索引:编号从0 开始,属于数值索引 注意:索引可支持使用自定义的格式,而不仅是数值格式,即为关联索引,bash4.0版本之后开始支持。而且bash 的数组支持稀疏格式(索引不连续) 1)、定义数组 声明数组: declare -a …

    Linux干货 2016-09-01
  • bind-9.9.5编译安装

    bind-9.9.5编译安装 §·bind-9.9.5编译安装大概步骤 步骤一 :下载源码包bind-9.9.5 ; 步骤二 :按需求选择模块或功能 ./configure ;  # ./configure  –prefix=/usr/local/bind9  –sysconfdir=…

    Linux干货 2016-10-09
  • 重定向和管道

     重定向    程序:指令+数据    读入数据:Input    输出数据:Output  linux给程序提供三种I/O设备    标准输入(stdin)-0 默认接受来自键盘的输入    标准输出(stdinout)-1默认输出到终端…

    Linux干货 2016-08-10
  • 磁盘分区、软RAID创建及shell脚本参数传递,for循环,运算表达式应用 1、创建一个10G分区,并格式为ext4文件系统。 先使用fdisk工具创建一个10G的新分区。使用fdisk打开要创建磁盘分区的物理设备fdisk /dev/sdb,然后使用n指令创建新的分区,分区类型选此处选择为主分区,第一个柱面使用默认的1,最后的柱面,使用+10G这种表示方…

    Linux干货 2016-12-26