Users and user groups under Linux

Source: Internet
Author: User

1, add a test group: Groupadd test

2. Rename the test group Test2:groupmod-n test2 test

3, delete test2 Group: Groupdel test2

4. View the group of the currently logged on user: groups

5, view APAC Group: Groups APAC

6. View all the groups in the system:cat/etc/group a group row with the group name: group Password: gid:[group user, if NULL indicates user group as GID user name]

If there is no/etc/group file, use this command to see: cat/etc/passwd |awk-f [:] ' {print $4} ' |sort|uniq | getent group |awk-f [:] ' {print $ } '

7. View all existing users in the system: Cat/etc/shadow This file is automatically generated by the Pwconv command according to the data in the/etc/passwd

Login: Encrypted password: Last modified: Minimum time interval: Maximum time interval: Warning Time: Inactivity time: Expiry time: Flag

cat/etc/passwd A user row, content is user name: password: uid:gid: User description: Home directory: Login Shell

The password value is x, the password is ciphertext, otherwise the password is plaintext.

Uid:0 is reserved for the root,1~99 system.

Login Shell value/sbin/nologin is not allowed to log on, such as pseudo-user and FTP user.

8, add Users: Useradd–help

Usage:useradd [Options] LOGIN

Options:

-b,–base-dir Base_dir Set the base path as the user's logon directory
-c,–comment comment comments to the user
-d,–home-dir Home_dir Setting the user's login directory
-d,–defaults changing settings
-e,–expiredate Expire_date Set the user's validity period
-f,–inactive inactive user expires, make password invalid
-g,–gid Group enables users to belong to only one group
-g,–groups groups enable users to join a group
-h,–help Help
-k,–skel Skel_dir Specify a different Skel directory
-k,–key key=value Overwrite/etc/login.defs configuration file
-m,–create-home Automatically create login directories
-L, do not add the user to the Lastlog file
-M, do not create the login directory automatically
-R, set up the system account
-o,–non-unique allows the user to have the same UID
-p,–password password using encrypted passwords for new users
-s,–shell Shell Login Time Shell
-u,–uid UID Specifies a UID for the new user
-z,–selinux-user Seuser use a specific seuser for the SELinux user mapping

Note: Useradd add a user, do not forget to give him a password (passwd username), otherwise you cannot log in.

9, delete User: Userdel test

10, modify User: usermod-d/home/test-g test2 Test Change the login directory of the test user to/home/test, and add the Test2 group, note that this is the big G.

11, modify user group: Gpasswd-a username groupname add

gpasswd-d username GroupName Delete

12, view current logged on User: W or who

View current Login user name: WhoAmI

13, view user information: ID username and finger username

14, view login record: Success: last failure: LASTB

15, view all users:cut-d:-F 1/etc/passwd cat/etc/passwd |awk-f \: ' {print $} '

16, modify user password: passwd username

User and user groups under Linux

Related Article

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.