Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Common commands for Linux user and group management

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "common commands for Linux user and group management". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. The user belongs to the user group

2. User and user group profile

1) user Group Profil

/ etc/group

First column: group name of the user group

Second column: group password (the real password is stored in gshadow)

The third column: user group ID, unique identity of user group

The superuser group with group ID of 0

Group ID is 1-499 is the system user group

Group ID greater than 500is a user-defined group

Fourth column: group members

2) user group password profile

/ etc/gshadow

First column: user group name

Second column: password

The third column: group administrator

Fourth column: group members

3) user profile

/ etc/passwd

First column: user name

Second column: user password, with only one x placeholder, password stored in shadow

The third column: user ID, unique ID

The user whose ID is 0 is the superuser.

Users whose ID is 1-499 are system users.

A user whose ID is greater than 500is a custom user

Fourth column: group ID of the group to which it belongs

Column 5: remarks

The sixth column: the user's home directory (home). When the user logs in to the system, he or she logs in at home.

The seventh column: shell type

4) user password profile

/ etc/shadow

First column: user name

The second column: password (! Indicates that there is no password and login is not allowed.

3. User group management

Groupadd group name add user group-g: specify group IDgroupmod group name when adding group modify user group information-n: modify group name-g: modify group IDgroupdel group name delete group * if there are users under a group, this group cannot be deleted.

4. User management

Useradd [parameters] user name add user-g group name specify group-d directory specify user home directory * when you add a user, if you do not specify a group, the system creates a group with the same name as the user. Usermod [parameter] user name-c comment modify remarks-l user name modify user name-d directory modify user home directory-g group name modify user group userdel [parameter] user name-r delete user home directory

5. Password management

Passwd [option] user name-S View user password status-l Lock the user's password (disable login)-u unlock the user's password-d Delete the user's password

6. Forbid account login

There are two situations:

Forbid a certain account to log in

/ etc/shadow

Modify shadow directly and add two before the user's password! The user is not allowed to log in. It is recommended to use: passwd-l user name this method to prevent users from logging in. All accounts are prohibited from logging in / etc/nologin to create nologin files under / etc/, and all users are unable to log in.

7. Add and delete group members

* usermod-g is the primary group gpasswd [option] group name of the modified user-a user name: add group member-d user name: delete group member

The default identity of a user after logging in is his primary group identity.

You can use newgrp to switch the identity of the group to which it belongs, as long as it also belongs to that group.

The group to which the current user identity is switched is the group to which the created file belongs.

This is the end of the content of "Common commands for Linux user and Group Management". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report