User and group exercises

Source: Internet
Author: User

1, create user Gentoo, additional group is bin and root, the default shell is/BIN/CSH, the annotated message is "Gentoo istribution"

[Email protected] ~]# useradd gentoo-g bin,root-s/bin/csh-c "Gentoo istribution"

Report

650) this.width=650; "title=" Create Gentoo.jpg "alt=" wkiom1efnr3hupxvaackeol4tu0075.jpg-wh_50 "src=" http://s1.51cto.com /wyfs02/m00/85/4a/wkiom1efnr3hupxvaackeol4tu0075.jpg-wh_500x0-wm_3-wmp_4-s_3540440307.jpg "/>
2. Create the following user, group, and group memberships
Group with the name Admins

[Email protected] ~]# groupadd Admins

Report

650) this.width=650; "title=" Create Admins.png "alt=" wkiom1efngcbgwswaabpkzvonso373.png-wh_50 "src=" http://s5.51cto.com /wyfs02/m02/85/4a/wkiom1efngcbgwswaabpkzvonso373.png-wh_500x0-wm_3-wmp_4-s_4100866224.png "/>

User Natasha, using admins as a subordinate group
[Email protected] ~]# useradd natasha-g Admins
Report

650) this.width=650; "title=" natasha.jpg "alt=" wkiol1efnqfb3xwcaaa7q_617gy604.jpg-wh_50 "src=" http://s1.51cto.com/ Wyfs02/m00/85/4b/wkiol1efnqfb3xwcaaa7q_617gy604.jpg-wh_500x0-wm_3-wmp_4-s_1246043561.jpg "/>

User Harry, also use admins as a subordinate group

[Email protected] ~]# useradd harry-g Admins

Report

650) this.width=650; "title=" harry.jpg "alt=" wkiom1efnxryfna_aaa4tzpxpru032.jpg-wh_50 "src=" http://s5.51cto.com/ Wyfs02/m02/85/4b/wkiom1efnxryfna_aaa4tzpxpru032.jpg-wh_500x0-wm_3-wmp_4-s_2323286692.jpg "/>

User Sarah, no interactive login system, and not a member of admins, Natasha,harry,sarah password is CentOS

[[email protected] ~]# useradd sarah-s/bin/nologin//non-interactive login system

[Email protected] ~]# echo "CentOS" | passwd--stdin Natasha//Add a password for CentOS
[Email protected] ~]# echo "CentOS" | passwd--stdin Harry//Add a password for CentOS
[Email protected] ~]# echo "CentOS" | passwd--stdin Sarah//Add a password for CentOS
Report

650) this.width=650; "title=" nologin.jpg "alt=" wkiol1efokwbwphcaacesv9vmek960.jpg-wh_50 "src=" http://s3.51cto.com/ Wyfs02/m00/85/4b/wkiol1efokwbwphcaacesv9vmek960.jpg-wh_500x0-wm_3-wmp_4-s_256070306.jpg "/>

3, create testuser UID 1234, primary Group: Bin, Auxiliary Group: ROOT,FTP,SHELL:/BIN/CSH Home:/testdir/testuser

[Email protected] ~]# useradd testuser-u 1234-g bin-g root,ftp-s/bin/csh-d/testdir/testuser

Report

650) this.width=650; "title=" 3.jpg "src=" http://s3.51cto.com/wyfs02/M02/85/4B/ Wkiom1efp4qaj-hpaacpewmqhni520.jpg-wh_500x0-wm_3-wmp_4-s_700941777.jpg "alt=" Wkiom1efp4qaj-hpaacpewmqhni520.jpg-wh_50 "/>

4, modify TestUser uid:4321, primary Group: root, Auxiliary Group: Nobody,loginname:test,home:/home/test Home Data migration
[Email protected] ~]# usermod testuser-u 4321-g root-g nobody-l test-d/home/test-m
Report

650) this.width=650; "title=" usermod.jpg "src=" http://s2.51cto.com/wyfs02/M01/85/4B/ Wkiol1efqg7a6bhiaaa2pxnbmus774.jpg-wh_500x0-wm_3-wmp_4-s_3852495750.jpg "alt=" Wkiol1efqg7a6bhiaaa2pxnbmus774.jpg-wh_50 "/>

5, Batch create account: User1...user10

1) First create a User.txt document format as follows:

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

Report

650) this.width=650; "title=" batch. jpg "src=" http://s2.51cto.com/wyfs02/M01/85/4B/wKioL1efRFzQhf7AAAB_5HjY_ 4o669.jpg-wh_500x0-wm_3-wmp_4-s_2563886944.jpg "alt=" Wkiol1efrfzqhf7aaab_5hjy_4o669.jpg-wh_50 "/>

Using the command: NewUsers and edit files

[Email protected] ~]# newusers user.txt

Report

650) this.width=650; "title=" newusers.jpg "src=" Http://s4.51cto.com/wyfs02/M01/85/4B/wKioL1efRTjQi7a_ Aadojj-vgbi327.jpg-wh_500x0-wm_3-wmp_4-s_1456601197.jpg "alt=" Wkiol1efrtjqi7a_aadojj-vgbi327.jpg-wh_50 "/>

Then create a new Passwd.txt document to write the password in format

Passwd:usernamepass

Report

650) this.width=650; "title=" passwd.jpg "src=" http://s4.51cto.com/wyfs02/M01/85/4C/ Wkiol1efrkydzfvaaaa5punmcq0291.jpg-wh_500x0-wm_3-wmp_4-s_1849588512.jpg "alt=" Wkiol1efrkydzfvaaaa5punmcq0291.jpg-wh_50 "/>

In use command: CHPASSWD import password

[email protected] ~]# Cat Passwd.txt | chpasswd

Report

650) this.width=650; "title=" chpasswd.jpg "src=" http://s1.51cto.com/wyfs02/M00/85/4C/ Wkiom1efr1bxvlacaagt9silvqi234.jpg-wh_500x0-wm_3-wmp_4-s_1561937639.jpg "alt=" Wkiom1efr1bxvlacaagt9silvqi234.jpg-wh_50 "/>

It's not over yet, and you need to copy all the files under/etc/skel/to 10 users.

[[email protected] ~]# for TestDir in user{1..10};d o cp-rf/etc/skel/. [^.] */testdir/$testdir;d One

Note Home directory-related configuration, so that users log on normally

This article from the "Operation and maintenance of the Future" blog, declined reprint!

User and group exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.