系統基礎之用戶,組管理作業題

、創建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.www58058.com/27639

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

相關推薦

  • vfork 掛掉的一個問題

    在知乎上,有個人問了這樣的一個問題——為什么vfork的子進程里用return,整個程序會掛掉,而且exit()不會?并給出了如下的代碼,下面的代碼一運行就掛掉了,但如果把子進程的return改成exit(0)就沒事。 我受邀后本來不想回答這個問題的,因為這個問題明顯就是RTFM的事,后來,發現這個問題放在那里好長時間,而掛在下面的幾個答案又跑偏得比較嚴重,…

    Linux干貨 2016-08-15
  • 硬鏈接與軟鏈接

    硬連接:          其本質就是:一個文件,多個名字。注意:目錄是沒有硬鏈接的。 用ln filename linkname創建硬鏈接,注意源文件和鏈接文件位置順序,硬鏈接不可以跨分區建。 在創建硬鏈接時會增加硬連接數,可以通過ls –l查看,如下圖所示的,可看到硬鏈接數。…

    2017-07-20
  • Linux磁盤管理

     I/O Ports:I/O設備地址   一切皆文件:             poen(),read(),write(),close()   設備類型:     &nb…

    Linux干貨 2016-08-29
  • mariadb數據庫的主從復制

    mariadb的主從復制

    2018-02-27
  • 初學Linux之快速獲取幫助

    Windows操作系統和Linux操作系統的界面區別,導致了初學Linux時,我們會遇到比較大的障礙。Windows操作系統時圖形這種形象化的操作界面,而Linux則不同,時以字符界面為主的。當我們遇到困難,我們可以獲取系統提供的幫助信息,越過我們遇到的障礙,快速的熟悉Linux。獲取幫助的方法包括:Linux手冊(man),命令的幫助頁,info幫助。

    2017-11-19
  • 第四周作業

    正則表達式練習

    Linux干貨 2017-12-25
欧美性久久久久