8.01 用戶組和權限管理練習

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

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


2、創建下面用戶,組和成員關係,名字爲admins的組,用戶natasha,使用admins作爲附加組,用戶harry,也使用admins,作爲附加組,用戶sarah,不可交互登陸系統,且不是admins成員,natasha,harry,sarah密碼都是centos

   groupadd admins

    useradd -G admins natasha

    useradd -G admins harry

    useradd -s /sbin/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


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

    groupadd loginname

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


5、批量創建帳號:user1...user10,uid:3000-3009,shell:/bin/csh,home:/testdir/username

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

    vim useradd.txt     

        user1:x:3000:3000::/testdir/username1:/bin/csh

        user2:x:3001:3001::/testdir/username2:/bin/csh

        user3:x:3002:3002::/testdir/username3:/bin/csh

        user4:x:3003:3003::/testdir/username4:/bin/csh

        user5:x:3004:3004::/testdir/username5:/bin/csh

        user6:x:3005:3005::/testdir/username6:/bin/csh

        user7:x:3006:3006::/testdir/username7:/bin/csh

        user8:x:3007:3007::/testdir/username8:/bin/csh

        user9:x:3008:3008::/testdir/username9:/bin/csh

    newusers useradd.txt

    vim pwd.txt     

        user1:123456

        user2:123456

        user3:123456

        user4:123456

        user5:123456

        user6:123456

        user7:123456

        user8:123456

        user9:123456

    cat pwd.txt | chpasswd

        


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