Linux Learning Commands Summary ⑦

Source: Internet
Author: User

#useradd命令: Set up user accounts and create a user's starting directory, using permissions is Superuser

[[Email Protected]_168_102_centos ~~]# ID testuid=502 (test) gid=502 (test)groups=502 ~]# Tail-n 1/etc/passwdtest:x:502:502::/home/test:/bin/bash

Useradd–u UID: Specify UID directly when creating user

[[Email Protected]_168_102_centos ~]# useradd-u 888~]# tail-n 1/etc/passwdtest_1:x:888:888::/home/ Test_1:/bin/bash

Useradd–g GID: Specify Gid,gid to be pre-existing when creating user

[Email protected]_168_102_centos ~]# useradd-g~]# tail-n 1/etc/passwdtest_2:x:889:500::/home/ test_2:/bin/~]# ID test_2uid=889 (test_2) gid=500 (Wanghan) groups=500~]# useradd-g 777  ' 777 ' does not exist

Useradd–g GID: Specify additional groups directly when creating a user, but the group must exist beforehand

[Email protected]_168_102_centos ~]# useradd-g~]# tail-n 1/etc/passwdtest_3:x:890:890::/home/ test_3:/bin/~]# ID test_3uid=890 (test_3) gid=890 (test_3) groups=890 (Test_3), (Wanghan)

Useradd–d: Specify the home directory when creating a user, and if this directory does not exist, you can create a master directory by using the-M option

[Email protected]_168_102_centos ~]# useradd-d/home/qidian-m test_6      ~]# tail-n 1/etc/passwdtest_6: X:893:893::/home/qidian:/bin/~]# ls/homeabc  ceshi  openstack  qidian  test  test_1  test_2  test_3  Wanghan

Description: –m: Forcing a user to create a home directory when creating a user

Useradd–m: Create user, but do not create home directory

[[Email Protected]_168_102_centos ~]# ls/homeabc  ceshi  openstack  qidian  test  test_1  Test_2  test_3  ~]# useradd-~]# tail-n 1/etc/passwdtest_7:x:895:895::/home/test_ 7:/bin/~]# ls/homeabc  ceshi  openstack  qidian  test  test_1  test_2  test_3  Wanghan

USERADD-C: Create user-specified annotated description, view in/ETV/PASSWD

[Email protected]_168_102_centos ~]# useradd-c wanghan test_9                                                 ~]# tail-n 1/etc/passwdtest_9:x: 897:897:wanghan:/home/test_9:/bin/bash

Useradd–s: Specify the default shell when creating a user, you should specify the shell that the/etc/shells file appears in

[Email protected]_168_102_centos ~]# useradd-' tcsh '~]#useradd-s/bin/~]# tail-n 1/etc/
   
    PASSWDTEST_10:X:898:898::/home/test_10:/bin/tcsh
   

#groupadd命令: Create a new group

[[Email Protected]_168_102_centos ~~]# tail-n 1/etc/grouphp:x:2001:

Groupadd–g GID: Create a new group and specify GID

[Email protected]_168_102_centos ~]# groupadd-g~]# tail-n 1/etc/groupwudi:x:~]#

#userdel命令: Delete user, home directory is reserved by default

[Email Protected]_168_102_centos ~]# Userdel test_9[[email protected]_168_102_centos~]# tail/etc/passwdtest_1:x:888:888::/home/test_1:/bin/bashtest_2:x:889:500::/home/test_2:/bin/bashtest_3:x:890:890::/home/test_3:/bin/bashtest_4:x:891:891::/home/abc:/bin/bashopenstack:x:892:892::/home/openstack:/bin/bashtest_6:x:893:893::/home/qidian:/bin/bashwanghan11:x:894:894::/tmp/wanghan:/bin/bashtest_7:x:895:895::/home/test_7:/bin/bashtest_8:x:896:896::/home/test_8:/bin/bashtest_10:x:898:898::/home/test_10:/bin/Tcsh[[email Protected]_168_102_centos~]# LS/homeabc ceshi openstack Qidian test test_1 test_10 test_2 test_3 test_8 test_9 Wanghan

Userdel-r: Delete User at the same time delete their home directory

[Email protected]_168_102_centos ~]# Userdel-R test_8[[email Protected]_168_102_centos~]# tail/etc/passwdtest:x:502:502::/home/test:/bin/bashtest_1:x:888:888::/home/test_1:/bin/bashtest_2:x:889:500::/home/test_2:/bin/bashtest_3:x:890:890::/home/test_3:/bin/bashtest_4:x:891:891::/home/abc:/bin/bashopenstack:x:892:892::/home/openstack:/bin/bashtest_6:x:893:893::/home/qidian:/bin/bashwanghan11:x:894:894::/tmp/wanghan:/bin/bashtest_7:x:895:895::/home/test_7:/bin/bashtest_10:x:898:898::/home/test_10:/bin/Tcsh[[email Protected]_168_102_centos~]# LS/homeabc ceshi openstack Qidian test test_1 test_10 test_2 test_3 test_9 Wanghan

#passwd命令: Set User password

Administrator to modify their own password:

[Email protected]_168_102_centos ~fornew  Password:passwd:all Authentication tokens updated successfully.

The administrator modifies the other user's password:

[Email protected]_168_102_centos ~fornew  Password:passwd:all Authentication tokens updated successfully.

User to modify their own password:

for For Wanghan. (  Current) UNIX password:    // Enter present password new password:           new  password : Passwd:all authentication tokens updated successfully.

Passwd–l: Lock user Password, user cannot change password

[[Email Protected]_168_102_centos ~]# passwd-for  Wanghan. ( Current) UNIX Password:passwd:Authentication token manipulation Error

Passwd–u: Unlock user password

[[Email Protected]_168_102_centos ~]# passwd-for  Wanghan. ( Current) UNIX password:new password:

Passwd–s: Display user Password summary information

[Email protected]_168_102_centos ~]# passwd-2014-08-12 0 99999 7-1 (Password set, SHA512 crypt.)

#usermod命令: Used to modify the settings of the user account

Usermod–u UID: Modify user UID

[[Email Protected]_168_102_centos ~]# ID openstackuid=892 (OpenStack) gid=892 (OpenStack) groups=892  ~]# usermod-u 588~]# ID openstackuid=588 (OpenStack) gid=892 (OpenStack) groups=892 (OpenStack)

Usermod–g GID: Modifying user gid

[[Email Protected]_168_102_centos ~]# ID wanghanuid=500 (Wanghan) gid=2000 (Wudi)groups=2000 ~]# USERMOD-G 2001~]# ID wanghanuid=500 (Wanghan) gid=2001 (HP) groups=2001 (HP)

Usermod–g GID: Modifies the user-attached group, overwriting the original additional group by default, while using the-a option to add additional

[Email protected]_168_102_centos ~]# ID user1uid=899 (user1) gid=899 (user1) groups=899 (user1),  ~]# usermod-g 2001~]# ID user1uid=899 (user1) gid=899 (user1) groups=899 (User1), 2001~]# Usermod-a-Gto]# ID user1uid=899 (user1) gid=899 (user1) groups=899 (user1), (Wudi), 2001 (HP)

Usermod–c: Modify user account note information

[Email protected]_168_102_centos ~]# useradd-~]# tail-n 1/etc/passwduser2:x:900:900:hello:/home/ user2:/bin/~]# usermod-~]# tail-n 1/etc/passwduser2:x:900:900:test:/home/user2:/bin/ Bash

Usermod-d: Modify the user home directory, the home directory is not migrated by default, while using-M can be migrated

[Email protected]_168_102_centos ~]# usermod-d/tmp/Wanghan user1 [[Email Protected]_168_102_centos~]# tail/etc/passwdtest_2:x:889:500::/home/test_2:/bin/bashtest_3:x:890:890::/home/test_3:/bin/bashtest_4:x:891:891::/home/abc:/bin/bashopenstack:x:588:892::/home/openstack:/bin/bashtest_6:x:893:893::/home/qidian:/bin/bashwanghan11:x:894:894::/tmp/wanghan:/bin/bashtest_7:x:895:895::/home/test_7:/bin/bashtest_10:x:898:898::/home/test_10:/bin/tcshuser1:x:899:899::/tmp/wanghan:/bin/bashuser2:x:900:900:test:/home/user2:/bin/Bash[[email Protected]_168_102_centos~]# usermod-d/tmp/user2/-m User2[[email Protected]_168_102_centos~]# tail/etc/passwdtest_2:x:889:500::/home/test_2:/bin/bashtest_3:x:890:890::/home/test_3:/bin/bashtest_4:x:891:891::/home/abc:/bin/bashopenstack:x:588:892::/home/openstack:/bin/bashtest_6:x:893:893::/home/qidian:/bin/bashwanghan11:x:894:894::/tmp/wanghan:/bin/bashtest_7:x:895:895::/home/test_7:/bin/bashtest_10:x:898:898::/home/test_10:/bin/tcshuser1:x:899:899::/tmp/wanghan:/bin/bashuser2:x:900:900:test:/tmp/user2/:/bin/bash

Usermod–s: Modifying the user shell

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.