8.1作業

8月1日作業

  1. 創建testuser uid 1234,主組:bin,輔助組:root,ftp,shell:/bin/csh home:/testdir/testuser

[root@localhost ~]# useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser
[root@localhost ~]# tail -1 /etc/passwd
testuser:x:1234:1::/testdir/testuser:/bin/csh
[root@localhost ~]# id testuser
uid=1234(testuser) gid=1(bin) groups=1(bin),0(root),50(ftp)

2.修改testuser uid:4321,主組:root,輔助組nobody,loginname:test,home:/home/test 家數據遷移

[root@localhost ~]# usermod -u 4321 -g 0 -G 99 -md /home/test -l test testuser
[root@localhost ~]# id test
uid=4321(test) gid=0(root) groups=0(root),99(nobody)
[root@localhost ~]# tail -1 /etc/passwd
test:x:4321:0::/home/test:/bin/csh

3.批量創建帳號:user1…user10 uid:3000-3009,shell:/bin/csh,home:/testdir/username passwd:usernamepass 注意家目錄相關配置,使用戶正常登錄 此題因為用戶太多,因此最后顯示了一個用戶成功,即為實驗成功。

8.1作業

[root@localhost ~]# newusers user.txt 
[root@localhost ~]# tail /etc/passwd
niu1:x:3000:3000::/testdir/username:/bin/csh
niu2:x:3001:3001::/testdir/username1:/bin/csh
niu3:x:3002:3002::/testdir/username2:/bin/csh
niu4:x:3003:3003::/testdir/username3:/bin/csh
niu5:x:3004:3004::/testdir/username4:/bin/csh
niu6:x:3005:3005::/testdir/username5:/bin/csh
niu7:x:3006:3006::/testdir/username6:/bin/csh
niu8:x:3007:3007::/testdir/username7:/bin/csh
niu9:x:3008:3008::/testdir/username8:/bin/csh
niu10:x:3009:3009::/testdir/username9:/bin/csh


[root@localhost ~]# vim user.txt
[root@localhost ~]# newusers user.txt 
[root@localhost ~]# tail /etc/passwd
niu1:x:3000:3000::/testdir/username:/bin/csh
niu2:x:3001:3001::/testdir/username1:/bin/csh
niu3:x:3002:3002::/testdir/username2:/bin/csh
niu4:x:3003:3003::/testdir/username3:/bin/csh
niu5:x:3004:3004::/testdir/username4:/bin/csh
niu6:x:3005:3005::/testdir/username5:/bin/csh
niu7:x:3006:3006::/testdir/username6:/bin/csh
niu8:x:3007:3007::/testdir/username7:/bin/csh
niu9:x:3008:3008::/testdir/username8:/bin/csh
niu10:x:3009:3009::/testdir/username9:/bin/csh
[root@localhost ~]# [root@localhost ~]# tail /etc/passwd
bash: [root@localhost: command not found...
[root@localhost ~]# niu1:x:3000:3000::/testdir/username:/bin/csh
-bash: niu1:x:3000:3000::/testdir/username:/bin/csh: No such file or directory
[root@localhost ~]# niu2:x:3001:3001::/testdir/username1:/bin/csh
-bash: niu2:x:3001:3001::/testdir/username1:/bin/csh: No such file or directory
[root@localhost ~]# niu3:x:3002:3002::/testdir/username2:/bin/csh
-bash: niu3:x:3002:3002::/testdir/username2:/bin/csh: No such file or directory
[root@localhost ~]# niu4:x:3003:3003::/testdir/username3:/bin/csh
-bash: niu4:x:3003:3003::/testdir/username3:/bin/csh: No such file or directory
[root@localhost ~]# niu5:x:3004:3004::/testdir/username4:/bin/csh
-bash: niu5:x:3004:3004::/testdir/username4:/bin/csh: No such file or directory
[root@localhost ~]# niu6:x:3005:3005::/testdir/username5:/bin/csh
-bash: niu6:x:3005:3005::/testdir/username5:/bin/csh: No such file or directory
[root@localhost ~]# niu7:x:3006:3006::/testdir/username6:/bin/csh
-bash: niu7:x:3006:3006::/testdir/username6:/bin/csh: No such file or directory
[root@localhost ~]# niu8:x:3007:3007::/testdir/username7:/bin/csh
-bash: niu8:x:3007:3007::/testdir/username7:/bin/csh: No such file or directory
[root@localhost ~]# niu9:x:3008:3008::/testdir/username8:/bin/csh
-bash: niu9:x:3008:3008::/testdir/username8:/bin/csh: No such file or directory
[root@localhost ~]# niu10:x:3009:3009::/testdir/username9:/bin/csh
-bash: niu10:x:3009:3009::/testdir/username9:/bin/csh: No such file or directory
[root@localhost ~]# 
[root@localhost ~]# vim passwd.txt
[root@localhost ~]# cat passwd.txt 
niu1:usernamepass
niu2:usernamepass
niu3:usernamepass
niu4:usernamepass
niu5:usernamepass
niu6:usernamepass
niu7:usernamepass
niu8:usernamepass
niu9:usernamepass
niu10:usernamepass
[root@localhost ~]# cat passwd.txt  |chpasswd 
[root@localhost ~]# tail /etc/shadow
niu1:$6$WXiO3VmN$4OgPAkSzGwiBQiYw/gKVJehBOBVPK4NuNba8IWHfaCJ8tuwM/GUlBFM.vLH5JQbErE1PEJ9UIvnobZ6yezUeY.:17015:0:99999:7:::
niu2:$6$b9gzw7SK$fR9xidWkNzI2WPvNbN3MU6BX7bkVTgzNdd/Xi4aAHzFazJlFM0nag5kDFp9US7tBkvuRE2HOdXrvSB3fF8m4t1:17015:0:99999:7:::
niu3:$6$UiPsk/b01MsVo/Y$GGSXqr.hgo2v3S0Te.ouQNfQLramLrw5DXPmqpanLVUogTebAgJc90snjBErjD/vw64eNNE0YNoenur/lhhIi.:17015:0:99999:7:::
niu4:$6$tljwV/POq$stgnqDlgeQZdHBRDx6xQ5cQ4Q981qfnSkCTPHeWaj5nmhQZMSAlPPQHuKFxDDd.3lTTYKBZvHzFwdfWiNKGSK1:17015:0:99999:7:::
niu5:$6$VjrEk/g4L9HQQJhC$XeReNC3o0aX38x1GpauS2jJz3O7a.G1ZsNNKEIEzUacBwb3m30txEJnZsp8.FiRz3BBY.LMsz5xB4taHhWaIw1:17015:0:99999:7:::
niu6:$6$2Ha.d/nM7G.$DFoa1cUilw7ChEYDkK2f5GWPNXalZ2C5jhri9teO80ussEmdc1HHgc0EbFTQoBcXmPHyxsLTklN0.7XbRusUR/:17015:0:99999:7:::
niu7:$6$XRSHd/bpv$KadPAQbYmMuPeKDnPJ54QY9TOsFf9Ew.f0SZT2GRqpuiOARLxTBmUnEpk5oTj6PqAeC1JIaWZxc.RiYWJD2YF/:17015:0:99999:7:::
niu8:$6$I1oQI3jd$3DFgubf9j0cDfivB5KdYuESQXpGJSZQpki9u.l8SwcwYQzrZlhRwi68nJ5U6LFkLkjYJ549d12Onp5InuKejx0:17015:0:99999:7:::
niu9:$6$f6rwb16B$AtGuH357U7GXEygwI/naCwcCzkN8.xhPjf5n0VfzrHvh06lFhErFkalMuBPeim8MT8wKUU5hTHtIU9IE/9pXZ/:17015:0:99999:7:::
niu10:$6$N18Me/fnAwmhMQo$IQFb5wMcjvQ2dYXo6hiFXKIgYA9z8FdCKonmCWsz/.PcUauWbEhGan3wEFjFA63L3dumqzaDYBgMV9C4YQRy3/:17015:0:99999:7:::


[root@localhost username]# cp -r /etc/skel/.[^.]* /testdir/username4
[root@localhost username]# cd ..
[root@localhost testdir]# cd username4
[root@localhost username4]# ls -A
.bash_logout  .bash_profile  .bashrc  .mozilla
[root@localhost username4]# cd ..
[root@localhost testdir]# cd username2
[root@localhost username2]# ls -A
.bash_logout  .bash_profile  .bashrc  .mozilla
[root@localhost username2]# su - niu2
[niu2@localhost ~]$

原創文章,作者:fighter,如若轉載,請注明出處:http://www.www58058.com/27426

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

相關推薦

  • mysql備份之xtrabackup

    mysql備份之xtrabackup(建議用來備份innodb) 下載地址:https://www.percona.com/downloads/XtraBackup/ 安裝xtrabackup [root@node1 ~]# yum install percona-xtrabackup 完全備份 節點一 修改配置文件,…

    Linux干貨 2016-07-19
  • 8月5日課堂筆記

    bash基礎及shell編程初步 bash的特性及bash腳本編程初步    操作系統硬件, 內核把底層硬件的復雜性給隱藏起來,統一輸出為一種系統調用,系統調用非常底層,把系統調用封裝成了庫。讓程序運行起來。用戶在創建時有一個默認shell。終點設備用來當做標準輸入和輸出。  要想與主機交互,需要一個【終端】,附著在終端接口程序:  &n…

    Linux干貨 2016-08-07
  • 基于NFS實現WordPress

    實驗內容: (1)主機IP nfs server IP :192.168.29.120 nfs server IP: 192.168.29.110 (2)要求 nfs server共享/data/web/ 、/data/mysql 兩個目錄 nfs client掛載nfs server共享的/data/web/的文件系統至/var/www/html;部署wo…

    2017-06-13
  • Homework Week-1 Linux基本

    1、描述計算機的組成及其功能。 計算機由硬件和軟件組成;硬件主要分為五部分:控制器,運算器、存儲器、輸入和輸出設備。軟件分為系統軟件和應用軟件。 控制器(Control):是整個計算機的中樞神經,其功能是對程序規定的控制信息進行解釋,根據其要求進行控制,調度程序、數據、地址,協調計算機各部分工作及內存與外設的訪問等。 運算器(Datapath):運算器的功能…

    Linux干貨 2016-08-15
  • Linux文件查找工具之find “大寶劍”

    一、文件查找工具常用軟件 locate:     locate命令其實是find -name的另一種寫法,但是要比后者快得多,原因在于它不搜索具體目錄,而是搜索一個數據庫/var/lib/locatedb,這個數據庫中含有本地所有文件信息。Linux系統自動創建這個數據庫,并且每天自動更新一次,所以使用locate命令…

    Linux干貨 2016-03-12
  • 磁盤管理

     磁盤管理  1 磁盤的結構  設備文件     I/O Ports: I/O設備地址 ? 一切皆文件: open(), read(), write(), close() ? 設備類型: 塊設備:block,存取單位“塊”,磁盤 字符設備:char,存取單位“字符”,鍵盤 ? 設備文件:關聯至一個設備驅動程序…

    Linux干貨 2016-08-26
欧美性久久久久