习题

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








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