習題

1.創建用戶gentoo,附加組爲bin和root,默認shell爲/bin/csh,註釋信息爲"Gentoo Distribution"


 useradd -G bin,root -s /bin/csh -c "Gentoo Distribution" gentoo

 wKiom1egEJLSj0XmAAAelso2pMs302.gif


2.創建下面的用戶、組和組成員關係

 名字爲admins 的組

 用戶natasha,使用admins 作爲附屬組

 用戶harry,也使用admins 作爲附屬組

 用戶sarah,不可交互登錄系統,且不是admins 的成員,

 natasha,harry,sarah密碼都是centos

    

   groupadd admins

   useradd -G admins natasha

   useradd -G admins harry

   useradd -s /bin/nologin sarah

   echo "centos" | passwd --stdin natasha

   echo "centos" | passwd --stdin harry

   echo "centos" | passwd --stdin sarah


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

        

   useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser


wKiom1egEwawxB0xAAA3OLfzags705.gif



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

  usermod -u 4321 -g root -G nobody -l test -m -d /home/test testuser


wKioL1egE3vhZkmGAABRJOsTlLw309.gif


5.批量創建帳號:user1...user10

uid:3000-3009,shell:/bin/csh,home:/testdir/username

passwd:usernamepass

注意家目錄相關配置,使用戶正常登錄

vim user

#!/bin/bash

#create user

for ((i=1,j=3000;i<=10,j<=3009;i++,j++))

 do

   /usr/sbin/useradd -u $j -s /bin/csh -d /testdir/user$i user$i

   echo "user$i" | /usr/bin/passwd --stdin user$i

   /usr/bin/cp -r /etc/skel/.[^.]* /testdir/user$i

#Centos6 是/bin/cp

 done

chmod +x user

./usr

wKiom1egIu-Rco7fAAAt9EDN12k041.gif

wKioL1egIu-AqZbAAABKlq0z05o581.gif


wKiom1egIjuS0WzhAAAb-qmtgII469.gif








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章