201508025 post-lesson command exercises Summary

Source: Internet
Author: User

Useradd

1.. command explanation:

Used to create a user

2. Command syntax:

useradd [Options] LOGIN

3. Command options:

useradd-d [Options]

-r: Create a System user

-U uid: Specifies uid;

-G GID: Specifies the base group to which the user belongs, which must exist beforehand

-C plus Note text, note text is saved in passwd's remarks column.

-d/path/to/somewhere: Specifies the user's home directory path; The location cannot exist beforehand, otherwise its user-related profile will be copied;/etc/skel

-S Shell: Sets the user's default shell;

Cat/etc/shells

-G GID,... : Specifies the additional group to which it belongs;

-M: Do not create home directory for users;

4. Usage examples:

Creates a HZMQ user that specifies uid:601 to specify additional groups for MyHome home directory/hzm/hzmqq

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b3c.tmp "border=" 0 "alt=" wps4b3c.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/2A/ Wkiom1xd5skqvyweaacj3m2wztg405.jpg "" 458 "height=" 113 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b4d.tmp "border=" 0 "alt=" wps4b4d.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/27/ Wkiol1xd6nqag41maaarg5vcnny499.jpg "" 803 "height=" 6 "/>

Groupadd

1. Order Explanation:

Used to create group users

2. Command syntax:

Groupadd [Options] Group

3. Command options:

-G,--gid GID is used to specify the Create group ID

-R: Creating a System Group

-F: Force creation

4. Usage examples

Create a Python group that specifies id:677:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b4e.tmp "border=" 0 "alt=" wps4b4e.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/2A/ Wkiom1xd5slsjceraaanjqo0p0e981.jpg "" 315 "height="/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b4f.tmp "border=" 0 "alt=" wps4b4f.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/27/ Wkiol1xd6nrgcez7aaanvfk_brs586.jpg "" 101 "height="/>

Create a System group user kkk:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b50.tmp "border=" 0 "alt=" wps4b50.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/2A/ Wkiom1xd5wmxix71aaax_fjp-ya686.jpg "" 244 "height="/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b51.tmp "border=" 0 "alt=" wps4b51.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/2A/ Wkiom1xd5slrnwlpaacmjzmwzmg849.jpg "" 332 "height=" 185 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b52.tmp "border=" 0 "alt=" wps4b52.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/2A/ Wkiom1xd5skwjcp_aaam8knrukk176.jpg "" 551 "height=" 6 "/>

ID 1, command explanation:

View user-related ID information

2. Command syntax:

ID [OPTION] ... [USERNAME]

3. Command options:

-u:uid

-g:gid

-g:groups

-n:name

4. Usage examples:

Displays the UID of the HZM user, gid,groups information:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b53.tmp "border=" 0 "alt=" wps4b53.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/27/ Wkiol1xd6nvbptvvaaa5crb7jje830.jpg "297" height= "Max"/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b54.tmp "border=" 0 "alt=" wps4b54.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/27/ Wkiol1xd6nvhnmmgaaaototmag4899.jpg "" 657 "height=" 6 "/>

Su

1. Order Explanation:

The SU command is used to switch the current user identity to another user's identity and to change the user account number and password to be entered.

Note: The root user su does not require a password for any user.

2. Command syntax:

Su [OPTION] ... [-] [USER [ARG] ...]

3. Command options:

Su USERNAME: Non-complete switching, non-login switching

Su-username or su-l USERNAME: full switch, login switch

4. Usage examples:

Non-login switch to HZM account:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b55.tmp "border=" 0 "alt=" wps4b55.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/27/ Wkiol1xd6nuyzqcjaaapiwo0lby976.jpg "" 241 "height="/>

Login switch to HZM account:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b56.tmp "border=" 0 "alt=" wps4b56.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/27/ Wkiol1xd6nvhwhsxaaajilsijj4372.jpg "" 214 "height="/>

Execute the ' whoami ' command once with the root user:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b67.tmp "border=" 0 "alt=" wps4b67.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/27/ Wkiol1xd6nvbbhvmaabqlgrvjuw525.jpg "" 296 "height=" 106 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b68.tmp "border=" 0 "alt=" wps4b68.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/27/ Wkiol1xd6nvsky2naaanrpaowa4549.jpg "" 604 "height=" 6 "/>

Usermod

1. Order Explanation:

Modify a user's properties

2. Command syntax:

3. Command options:

-C Modify User comment information

-D Modify the user home directory-m to modify the home directory and then copy the user's original files to this

-G Modify the user's base group

-G Modify the user's additional group

-A is used together with-G to indicate that the user is added to the newly specified additional group and retains the original

-L Modify the user's login name

-S modifies the user's default shell

-L administrators can use a locked user

-U Unlock User

4. Usage examples:

To modify a basic group of HZM users:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b69.tmp "border=" 0 "alt=" wps4b69.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/27/ Wkiol1xd6nzgtngxaacmmv2uloi105.jpg "324" height= "/>"

Modify the Hzm user to add additional groups to HZM1:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b6a.tmp "border=" 0 "alt=" wps4b6a.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/2B/ Wkiom1xd5stdh9wtaacqxevkz9c934.jpg "" 558 "height=" 103 "/>

Add additional group hzm2 for HZM1:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b7a.tmp "border=" 0 "alt=" wps4b7a.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/27/ Wkiol1xd6nywxpblaabxrayjshe017.jpg "" 461 "height="/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b7b.tmp "border=" 0 "alt=" wps4b7b.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/27/ Wkiol1xd6nyywt14aaaqwug39wa047.jpg "" 784 "height=" 6 "/>

Chsh

1. Order Explanation:

Modifying the user shell

2. Command syntax:

Chsh [-S Shell] [-l] [-u] [-v] [username]

3. Command parameters:

-l lists the available shells for the system

-S Modify the specified shell

4. Usage examples:

List system available Shells:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b7c.tmp "border=" 0 "alt=" wps4b7c.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/27/ Wkiol1xd6nysaegiaabde0goddk248.jpg "" height= "103"/>

Modify the Hzm Shell to/bin/sh:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b7e.tmp "border=" 0 "alt=" wps4b7e.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/27/ Wkiol1xd6n3btuueaabylqb0vbc722.jpg "" 285 "height="/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b7d.tmp "border=" 0 "alt=" wps4b7d.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/2B/ Wkiom1xd5sxbyemcaaandmhdrum212.jpg "" 586 "height=" 6 "/> Chfn

1. Order Explanation:

Modify User Comment Information

2, Command parameters:

CHFN [-F full-name] [-O Office], RB [-P office-phone] [-H Home-phone]-u] [-v] [username]

3. Usage Examples:

.650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b7f.tmp "border=" 0 "alt=" wps4b7f.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/27/ Wkiol1xd6n3qamq7aaer7zmnocu687.jpg "" 455 "height=" 282 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b80.tmp "border=" 0 "alt=" wps4b80.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/2B/ Wkiom1xd5ygaiy_daaanv3bxioq236.jpg "" 606 "height=" 6 "/>

passwd

1. Order Explanation:

2. Command syntax

passwd [-K] [-l] [-u [-f]] [-d] [-e] [-N mindays] [-X Maxdays] [-W warndays] [-I inactive-days] [-S] [--stdin] [username]

3. Command options:

-L Lock User

-U Unlock User

--stdin Standard input

4. Usage examples:

Use--stdin to configure the password for hzm2:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b91.tmp "border=" 0 "alt=" wps4b91.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/2B/ Wkiom1xd5sxdcunkaacnw0hzsls631.jpg "" 420 "height=" 106 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b92.tmp "border=" 0 "alt=" wps4b92.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/2B/ Wkiom1xd5ygil7t9aaamlqo80tq031.jpg "" 540 "height=" 6 "/>

Userdel

1. Order Explanation:

Delete User

2. Command syntax:

Userdel [Options] LOGIN

3. Command options:

-R Delete User at the same time delete user home directory

4. Usage examples:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b93.tmp "border=" 0 "alt=" wps4b93.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/2B/ Wkiom1xd5sxba-pzaaaz5g6qoyw200.jpg "" 233 "height="/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b94.tmp "border=" 0 "alt=" wps4b94.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/27/ Wkiol1xd6tmjfjjxaaamvjofpqw552.jpg "" 523 "height=" 6 "/>

Groupmod

1. Order Explanation:

Modify Group Properties

2. Command syntax:

groupmod [Options] GROUP

3. Command options:

-G Modify Group ID

-N Modify the name of the group

4. Usage examples:

Modify the GID for the HZM2 group to be 681:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4b95.tmp "border=" 0 "alt=" wps4b95.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/2B/ Wkiom1xd5sbrflppaaehe-lamzi075.jpg "" 290 "height=" 387 "/>

Modify the name of the HZM2 group to HZM3:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4ba5.tmp "border=" 0 "alt=" wps4ba5.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/2B/ Wkiom1xd5sbr5uijaacfdd0hpv4708.jpg "" 314 "height=" 211 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4ba6.tmp "border=" 0 "alt=" wps4ba6.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/2B/ Wkiom1xd5sbrfayaaaalukn16zk591.jpg "" 488 "height=" 6 "/>

gpasswd

1. Order Explanation:

Set the group password, save the file to Gshadow

Toggle Base Group for group development

2. Command syntax:

GPASSWD [option] Group

3. Command options:

-A: Adding users to Groups

-D: Remove a user from a group

-R: Remove password

3. Usage Examples:

To create a group password for the HZM3 group:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4ba7.tmp "border=" 0 "alt=" wps4ba7.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/2B/ Wkiom1xd5sbtr6rqaabams9ro7a729.jpg "" 268 "height="/>

SU switches to HZM using NEWGRP to HZM3 Group

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4ba8.tmp "border=" 0 "alt=" wps4ba8.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/2B/ Wkiom1xd5sejxrw3aabykppq-gc476.jpg "" 311 "height="/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4ba9.tmp "border=" 0 "alt=" wps4ba9.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/2B/ Wkiom1xd5yhcysdjaaancftkvzs381.jpg "" 581 "height=" 6 "/>

Newgrp

1. Order Explanation:

Toggle Toggle Basic Group for the specified group

2. Command syntax:

NEWGRP [-] [group]

3. Usage Examples:

Su to the HZM user to change the HZM group to HZM1

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4bab.tmp "border=" 0 "alt=" wps4bab.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/27/ Wkiol1xd6n-i-ohtaacepdmtiok191.jpg "" 363 "height=" 118 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4baa.tmp "border=" 0 "alt=" wps4baa.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/2B/ Wkiom1xd5yhd16lcaaaor2t9hwk662.jpg "" 640 "height=" 6 "/> Groupdel

1. Order Explanation:

Delete a group

2. Command syntax:

Groupdel Group

3. Usage Examples:

Delete a KKK group

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4bac.tmp "border=" 0 "alt=" wps4bac.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/2B/ Wkiom1xd5tmrkq8kaabvvtrs7ga875.jpg "" "height=" 129 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4bbd.tmp "border=" 0 "alt=" wps4bbd.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/27/ Wkiol1xd55ohpajhaabspwh88aa928.jpg "" "height=" 168 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4bbe.tmp "border=" 0 "alt=" wps4bbe.tmp "src=" http://s3.51cto.com/wyfs02/M01/72/2B/ Wkiom1xd5yhjn88aaaanwjmdub8488.jpg "" 601 "height=" 6 "/>

Chage

1. Order Explanation:

Modify the properties of user account and password

2. Command syntax:

chage [Options] [LOGIN]

3. Command options:

-D: The date of the last change.

-E: The date when the account expires. This account will not be available after this day.

-L: Example the current setting. By non-privileged users to determine when their password or account expires.

-M:-M: The minimum number of days the password can be changed. At zero, the password can be changed at any time.

-M:-M: The maximum number of days the password remains valid.

-W: The number of days before the user's password expires before the warning message is received.

4. Usage examples:

To save the root user password for the maximum number of days to 50:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4bbf.tmp "border=" 0 "alt=" wps4bbf.tmp "src=" http://s3.51cto.com/wyfs02/M02/72/2B/ Wkiom1xd5tryrramaadq4f1y41g544.jpg "" 515 "height=" 159 "/>

Set the root password deadline to 5 days:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" wps4bc0.tmp "border=" 0 "alt=" wps4bc0.tmp "src=" http://s3.51cto.com/wyfs02/M00/72/27/ Wkiol1xd6plybjlpaaek5brzgyy060.jpg "" 506 "height=" 159 "/>

201508025 Post-lesson command Practice summary

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.